relabel x axis tick marks
13 次查看(过去 30 天)
显示 更早的评论
Hi,
Sorry for what seems an easy question, but I have been searching and have not found the answer.
I want to relabel the data points on the x-axis. Currently the x-axis is axis([0.27 0.9 0 1]) and I want the values shown to range from 30 to 85 rather than 0.27 to 0.9. So where the graph currently had label 0.27 on the x axis, replace that with 30 and so on upto replacing 0.9 with 85.
axis([30 85 0 1]) obviously puts the axis out of range of the data. Hope that makes sense, thanks in advance,
Rhys
0 个评论
采纳的回答
Walter Roberson
2011-8-2
set() the XTickLabel to whatever cell array of strings that you want.
It would be easier if there was a nice formula for determining the bounds. For example, .27 * (1000 / 9) gives 30, but .9 * (1000/9) gives 100 rather than the desired 85. There is a linear formula given those two bounds, but it is 87.3015873015873 * x + 6.42857142857143 which seems too ugly to be plausible.
2 个评论
Walter Roberson
2011-8-2
You want a tick range of 55 (30 to 85) over an axis range of 0.63 . Are you sure these are the correspondences you want?
更多回答(2 个)
Fangjun Jiang
2011-8-2
set the 'XTickLabel' property of the axes.
h=axes;
get(h,'XTickLabel') % shows 0 to 1
set(h,'XTickLabel',num2str((1:11)')) %shows 1 to 11
2 个评论
Walter Roberson
2011-8-2
You indicate to set the XTick property but show setting the XTickLabel property.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!