change the xticklabel with date format

16 visualizaciones (últimos 30 días)
Rt Ro
Rt Ro el 8 de Mayo de 2019
Comentada: Rt Ro el 9 de Mayo de 2019
I want to show all dates in the x-axis of the below fig. (jan 71, jan 72, ...)
and please tell me how I can remove the labels of second y axis after 20 (the black circles) ?
could you please help me.
Eforc=load('forc.txt');
P=Eforc(:,5);
Q=Eforc(:,4);
date = datenum(Eforc(366:end ,1:3));
[ax,h1,h2] = plotyy(date,Q(366:end),date,P(366:end),'plot', 'bar');
set(ax(2), 'Ydir', 'reverse','YTick',[0,10,20]);
ylim(ax(1), [0 3]);
set(h2,'EdgeColor','[0 0.45 0.74]','faceColor','[0 0.45 0.74]');
ylim(ax(2), [0 90]);
st=(date(1));
se=(date(end));
% ax(1).XTickLabel = [st se];ax(2).XTickLabel = [st se];
% set(gca,'xtick');
set(ax(1),'xlim',[st se],'FontSize',12,'FontName', 'Times New Roman');
set(ax(2),'xlim',[st se],'FontSize',12,'FontName', 'Times New Roman');
% legend('show');
datetick('x','mmmyy','keeplimits');

Respuesta aceptada

Rik
Rik el 8 de Mayo de 2019
I don't know if there is a control for the non-marked ticks, but maybe box does something you like.
For the ticks, you should be able to use datetick to get there ( 'mm yy' as format should work).
  8 comentarios
Walter Roberson
Walter Roberson el 9 de Mayo de 2019
With that data and your release then using datetime instead of datenum would be cleaner.
Rt Ro
Rt Ro el 9 de Mayo de 2019
thank you so much. I changed datetime and keepticks instead of keeplimits, then the problem was solved.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by