How can I add more tick marks between my x-axis labels?

62 ビュー (過去 30 日間)
Olivia Licata
Olivia Licata 2018 年 1 月 10 日
コメント済み: Olivia Licata 2018 年 1 月 12 日
My x-axis on a histogram goes from [0 80] in steps of 10 when I plot by default. I have altered my bin size to 0.5 and I would like my tick marks to occur every 0.5 or every 1.5 so that these values can be better interpreted. I only want the value labels on the x-axis every 5 or 10 (since that is all that will fit without overlapping).
In the code below, I have tried to use minor tick marks and different ways of assigning tick mark locations, but when I adjusted the labels, the values went to the first 10 ticks and did not distribute out (since they are characters).
if true
hINT=histogram(Zint(:,2), 'BinWidth', 0.5)
title('Histogram Interface')
xlim([0 80])
ax.XMinorTick = 'on'
%set(gca, 'XTick', 0:0.5:80)
%xticks(0:0.5:80)
%xticklabels({'0','10','20','30','40','50','60','70','80'})
end
Thank you in advance for any help!

採用された回答

Jan
Jan 2018 年 1 月 11 日
編集済み: Jan 2018 年 1 月 11 日
hINT = histogram(Zint(:,2), 'BinWidth', 0.5)
title('Histogram Interface')
xlim([0 80])
ax = hINT.Parent; % Important
set(ax, 'XTick', 0:0.5:80)
This should be enough, because Matlab sets the tick labels automatically.
  1 件のコメント
Olivia Licata
Olivia Licata 2018 年 1 月 12 日
This works if I use the following:
hINT=histogram(Zint(:,2), 'BinWidth', 0.5)
title('Histogram Interface')
xlim([0 80])
ax=hINT.Parent;
ax.XMinorTick = 'on' %more tick marks
set(ax, 'XTick', 0:5:80) %only want labels every 5 numbers

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid 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