7

大多数 MATLAB 绘图命令允许您指定要作用于哪些轴,例如

plot (x,y) 

在当前坐标区中绘制,但是

plot(Ax, x, y) 

将绘制在轴 Ax 上。

同样,您可以标记非活动轴的 x 轴或 y 轴

xlabel(Ax, 'this label goes on the x-axis of Ax whether or not Ax == gca')

但 text 命令似乎不支持此功能。有没有办法将文本放入非活动轴?

我问是因为这个序列:

currentAxes = gca;
axes(Ax); %MLINT warning here
text(x,y,'this text ends up on axes Ax now');
axes(currentAxes); %MLINT warning here

将抛出 MLINT 警告,即在脚本函数中调用轴(axes_handle)很慢。

4

1 回答 1

14

在调用文本命令时使用“父”属性

text(x,y,'text','Parent', Ax)
于 2010-09-21T13:13:57.613 回答