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

In Matlab, if we do not rotate the y-tag containing several letters, the tag can overlap with tick numbers or even with the y axis. We can increase the distance between the y-mark and the y-axis as follows:

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, the problem is that if we change axis([0 1 0 25])to axis([0 10 0 25]), the distance between the y-mark and the y-axis will also change. Is there a convenient way to shift the y-tag a little to the left, but keep the distance between the y-tag and the constant y-axis when we change the x range?

+5
source share
1 answer

You can use normalized units for the y-tag position. Try the following:

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

[0 1], .

+17

All Articles