How do I handle my axes after using 'pcolor' to plot a time series result?
2 次查看(过去 30 天)
显示 更早的评论
Good day, I used pcolor to plot a time series data, which is an M by N matrix. However, Im having dificulty in handling the axes, expecially the X-axis, because it display all the years (as in the image below) and that make the labes very crowdy and difficult to read. I use these codes;
%% CrtHYDL is the data (result), which is 81 by 156 matrix
%% IDS is a 1 by 81 matrix, containing list of names (characters) of the various 81 stations.
%% the X-axis should represent the 156 monthly values from January 1,2005 to December 31, 2017.
%% the Y-axis should represent the 81 stations.
figure
t1 = datetime(2005,1,1)+calmonths(0:155);
t = datevec(t1);
C1 = pcolor(CrtHYDL);
colormap(jet);
C = colorbar;
xlabel('Time (years)','FontName', 'Times New Roman','FontWeight','bold','FontSize',12);
ylabel('GPS Stations','FontName','Times New Roman','FontWeight','bold','FontSize',12);
ylabel(C,'Hydrological Load Deformation (mm)','FontName','Times New Roman','FontSize',12,'Fontweight','bold');
shading flat;
ax = gca
set(ax,'FontSize',6);
set(ax,'XTick',(1:size(CrtHYDL,2)+0.5));
set(ax,'YTick',(1:size(CrtHYDL,1)+0.5));
set(ax,'XTickLabel',{'2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017'});
set(ax,'YTickLabel',IDS);
set(ax,'XTickLabelRotation',45);
and I got this plot;
So my challenge is How to edit my script to make the X-axis have just one Ticks and one Label (years) for each year (from 2005 to 2017). Also for the Y-axis, though the axis is Labeled like i wanted it to, I need the Ticks to be visible.
I,m using R2016a.
I would humbly appreciate your assistance and guide. Thank you.
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!