Too many points on x-axis
19 次查看(过去 30 天)
显示 更早的评论
If you run the following script, Matlab uses 0.5 increments on the x-axis. This gives the wrong label, since it starts over again after 6 points on the x-axis. Does anybody know how to make sure that the increments are made so that the labels get correct?
test= rand(11,8,6);
test2=test
Alder = {'<20', '2029','3039','4049','5059','6069','>70', 'all'};
Aar = {'2011', '2012', '2013_1', '2014_1', '2014_s2', '2014_s5'};
nAlder = length(Alder);
nAar = length(Aar);
figure
hold on
for iAlder = 1:nAlder
plot(squeeze(test2(11,iAlder,:)));
set(gca, 'XTickLabel',Aar)
end
hold off
0 个评论
回答(2 个)
Jan
2013-6-5
Perhaps this helps:
figure
data = squeeze(test2(11, :, :));
plot(1:length(Alder), data); % perhaps: data.'
set(gca, 'XTickLabel', Aar, 'XTick', 1:length(Alder))
2 个评论
Iain
2013-6-5
No. It simply comes up with what matlab reckons the best scaling is for the plot. It seems to try to ensure that there are BETWEEN 7 and 11 ticks.
Try:
for i = 1:30
figure
plot(randn(i,1))
end
You'll see what I mean.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!