Noel Puldon
Noel Puldon

Reputation: 3

Matlab date help on x-axis

I have a porkchop plot that looks similar to this:

The contour function used to make it has input arguments for the x and y positions that are serial dates (as that seemed to be required by MATLAB). Then I used the following command to get the format I want:

datetick('x', 2); datetick('y', 2);

The problem I am having is that when I zoom in on the plot the tick labels to not autogenerate and I can be left with no ticks on the x or y axis if I zoom in to use a weeks' date range for example.

I tried enabling 'auto' for XtickMode and YtickMode but when I zoom in or pan after using those commands the relationship between the independent and dependent variables are lost for some reason (aka the dates don't stay with data like they do when you just have numbers on the x axis and zoom in).

Any ideas on how to solve this issue to get the functionality I'm looking for?

I have also tried the command xtickformat('dd-MMM-yy') but I get an error "Invalid numeric tick label format." when I use it with the contour plot.

Upvotes: 0

Views: 697

Answers (1)

MrAzzaman
MrAzzaman

Reputation: 4768

As far as I know there is no builtin method in MATLAB to do this. I use the datetickzoom function from the MATLAB FileExchange. If you replace all instances of datetick with datetickzoom, it will automatically update the relevant axis labels when you zoom in.

Upvotes: 1

Related Questions