|
"Steven_Lord" <slord@mathworks.com> wrote in message <k0te6v$ed8$1@newscl01ah.mathworks.com>...
>
>
> "Robbie Brady" <robbie.brady@postgrad.plymouth.ac.uk> wrote in message
> news:k0ntlh$k1a$1@newscl01ah.mathworks.com...
> > I am having issues displaying specified xtick labels using 'XTick.'
> >
> > My code looks as follows:
> > figure (3)
> > hold on
> > plot (radardate, Pwave_radar);
> > plot (radardate, mean_Pwave_radar,'r')
> > hold off
> > legend ('Wave Power', 'Mean Wave Power')
> > title ('WERA HF Radar Derived Wave Power Cell 3592')
> > ylabel ('Power (W/m^2)')
> > datetick('x')
> > set(gca,'XTick',xdata)
> >
> > where xdata is an array created by the command:
> >
> > xdata = [734947;734954;734961;734968;734975;734982;734989;734996];
> > The corresponding string dates are 19/03/2012, 26/03/2012, 02/04/2012 etc
> > etc...
> >
> > However, when plotted, matlab returns dateticks for the 1st of each month,
> > march-june... 03/01, 04/01 etc etc...
> >
> > Any ideas? This is giving me a headache...
>
> You didn't tell DATETICK to keep the exact tick locations you specified, so
> it chose ones that "looked nice." As Bruno posted, use the 'keepticks' and
> 'keeplimits' options with DATETICK; see the documentation for that function
> for more information on those options.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
Thanks guys, I wasn't aware of the 'keepticks' function before, but the code works perfectly now.
Cheers
|