大多数 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)很慢。