How to change number of ticks, tick position, and value on plot?
41 次查看(过去 30 天)
显示 更早的评论
I have a bar3 plot but the axis values and positioning of ticks are wrong. I want the axis, ticks, and tick values to look as such in the figure without the data. But when I plot my data, the axis looks like this instead. Can someone please tell me what I am doing wrong? Thank you in advance. This is the code that I have.
h = bar3(cell2mat(hrPax));
set(gca,'XTickLabel',[103.6 103.7 103.8 103.9 104]);
set(gca,'YTickLabel',[1.5 1.45 1.4 1.35 1.3 1.25]);
axis tight;
for kk = 1:numel(h)
h(kk).CData = h(kk).ZData;
h(kk).FaceColor = 'interp';
end


0 个评论
回答(1 个)
dpb
2017-6-16
编辑:dpb
2017-6-16
Set the tick values and the limits, not tick labels. Tick labels just write the label values on the tick marks that have been otherwise set by the auto-scaling routines; they have nothing to do with how many or what the actual values are.
set(gca,'XLim',[103.6 104],'XTick',[103.6:0.10:104])
set(gca,'XLim',[1.25 1.50],'YTick',[1.25:0.05:1.50])
NB:
You don't show actual data; you've written the 'yticklabel' in descending order; that may not be the same as the ticks themselves unless you've previously done
set(gca,'ydir','reverse')
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!