如何在Matlab中调整y标签和y轴之间的距离? [英] How to adjust the distance between the y-label and the y-axis in Matlab?

查看:1749
本文介绍了如何在Matlab中调整y标签和y轴之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab中,如果我们不旋转包含多个字母的y标签,则该标签可能会与刻度编号甚至y轴重叠.我们可以通过以下方式增加y标签和y轴之间的距离:

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

但是,问题是,如果我们将axis([0 1 0 25])更改为axis([0 10 0 25]),则y标签和y轴之间的距离也会改变.是否有一种方便的方法可以将y标签稍微向左移动,但是当我们更改x的范围时,保持y标签与y轴之间的距离恒定?

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?

推荐答案

您可以对y标签位置使用归一化的单位.试试这个:

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

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

归一化单位始终相对于[0 1],因此数据范围无关紧要.

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

这篇关于如何在Matlab中调整y标签和y轴之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆