How to create pseudo x-axis (or y-axis) tick labels?
8 次查看(过去 30 天)
显示 更早的评论
I'm writing a program that requires me to change the x or y values by a factor in order to address a bug within Matlab. For example, if my current x-axis values are [0:10:100] and I have to divide the current x values by 33.3 so that the actual x-axis values in the plot will be [0:0.3:3], how do I set the x-axis tick labels, so that my users would still see the original [0:10:100] values as the x tick label?
What is the function to come up with the default x-axis tick values?
Many thanks!
3 个评论
采纳的回答
dpb
2019-10-16
With the background as to "why", basic idea would be something like
Ratio=100/3; % the divisor for modifying the actual plotted values
hL=plot(x,y); % plot original data to get default axis pretty labels.
hAx=gca; % get the axes handle
xtk=xticks; % retrieve the tick values
delete(hL); hL=plot(x/Ratio,y); % remove original line; replace with scaled x values
hAx.XTicks=xticks/Ratio; % set ticks at original scaled values
hAx.XTickLabel=xticks; % write the labels to match the original unscaled values
0 个评论
更多回答(0 个)
另请参阅
类别
在 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!