Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
datetick step

Subject: datetick step

From: edward kabanyas

Date: 17 Aug, 2011 03:02:29

Message: 1 of 2

Hi all,

I want to generate a contour plot with Y-axis being date as:

levels=0.1:0.2:2.1;
[cs,cs]=contourf(lon,idate,data_p, levels);
set(cs,'edgecolor','none');
datetick('y','yyyymmdd', 'keepticks');
set(gca, 'YDir', 'reverse')
colormap(jet(23));
colorbar('location','northoutside')
xlim([90 150])
ylim([min(idate) max(idate)])
hold off

the date star from 1 April 2004 - 30 April 2004 with 3 hours step. I hope to show the Ythick label for each month (1 April 2004, 2 April 2004, ..., 30 April 2004). With the above setting, the plot shows the Ythick label as 20040403, 20040408, ..., 20040428, far from my expectation.

Question, is it not possible to adjust the step of datetick ? Thanks for sharing..

Edward

Subject: datetick step

From: edward kabanyas

Date: 17 Aug, 2011 04:15:13

Message: 2 of 2

I got the solution, by using:

levels=0.0:0.1:2.1;
[cs,cs]=contourf(lon,idate,data_p, levels);
set(cs,'edgecolor','none');

firstDays = datenum(2004,4,1:30,0:23,0,0);
% Update the tick locations
set(gca, 'YTick', firstDays);

datetick('y','yyyymmdd','keepticks');
%set(gca,'YTick',[y(1):1:y(end)])
set(gca, 'YDir', 'reverse')
colormap(jet(23));
colorbar('location','northoutside')
xlim([90 150])
% Make sure the axes spans the entire year
ylim(idate([1 end]))
hold off

Sorry for bothering you..

Edward

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <j2fb05$hva$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I want to generate a contour plot with Y-axis being date as:
>
> levels=0.1:0.2:2.1;
> [cs,cs]=contourf(lon,idate,data_p, levels);
> set(cs,'edgecolor','none');
> datetick('y','yyyymmdd', 'keepticks');
> set(gca, 'YDir', 'reverse')
> colormap(jet(23));
> colorbar('location','northoutside')
> xlim([90 150])
> ylim([min(idate) max(idate)])
> hold off
>
> the date star from 1 April 2004 - 30 April 2004 with 3 hours step. I hope to show the Ythick label for each month (1 April 2004, 2 April 2004, ..., 30 April 2004). With the above setting, the plot shows the Ythick label as 20040403, 20040408, ..., 20040428, far from my expectation.
>
> Question, is it not possible to adjust the step of datetick ? Thanks for sharing..
>
> Edward

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us