问题
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