How to change number of ticks, tick position, and value on plot?

조회 수: 236 (최근 30일)
Atiqah Zakirah
Atiqah Zakirah 2017년 6월 16일
편집: dpb 2017년 6월 16일
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

답변 (1개)

dpb
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')

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by