How to adjust the distance between the y-label and the y-axis in Matlab?

二次信任 提交于 2019-11-30 08:38:59

问题


In Matlab, if we do not rotate the y-label that contains several letters, the label may overlap with the tick numbers or even the y-axis. We can increase the distance between the y-label and the y-axis in the following way:

plot(A, B);
y=ylabel('xxx', 'rot', 0);  % do not rotate the y label
set(y, 'position', get(y,'position')-[0.1,0,0]);  % shift the y label to the left by 0.1

However, a problem is that if we change axis([0 1 0 25]) to axis([0 10 0 25]), the distance between the y-label and the y-axis will also change. Is there a convenient way to shift the y-label slightly to the left, but keep the distance between the y-label and the y-axis constant when we change the range of x?


回答1:


You can use normalized units for the y-label position. Try this:

set(y, 'Units', 'Normalized', 'Position', [-0.1, 0.5, 0]);

Normalized units are always relative to [0 1], so the range of your data doesn't matter.



来源:https://stackoverflow.com/questions/14611259/how-to-adjust-the-distance-between-the-y-label-and-the-y-axis-in-matlab

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