Adding text to y-axis - MATLAB

不羁岁月 提交于 2019-12-13 04:19:25

问题


I have a plot and I would like to add on the y-axis the values of 1σ, 2σ, 3σ etc. instead of numbers assigned by MATLAB. However, the x-axis remains as normal. Is there any way to do this?

Thanks


回答1:


Changing the tick labels is easy, as you can see from the following example.

x = 0:pi/500:2*pi;
y = sin(x);
plot(y, x);
set(gca, 'YTick', [0 pi/2 pi 1.5*pi 2*pi]);
set(gca, 'YTickLabel', {'0', 'pi/2', 'pi', '3/2 pi', '2 pi'});

However, the (la)tex interpreter is still unsupported and hence you should consider to replace the labels with text objects.

Some attempts to solve this problem can be found in:

http://blogs.mathworks.com/pick/2007/09/24/tex-interpreter-in-x-tick-and-y-tick-labels/

http://www.mathworks.com/matlabcentral/fileexchange/15986-format-tick-labels

http://www.mathworks.com/matlabcentral/fileexchange/16003-tick2text--create-easy-to-customize-tick-labels

http://www.mathworks.com/matlabcentral/answers/102053-how-can-i-make-the-xtick-and-ytick-labels-of-my-axes-utilize-the-latex-fonts-in-matlab-8-1-r2013a



来源:https://stackoverflow.com/questions/24913010/adding-text-to-y-axis-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!