如何在 Matlab 中为非当前图形创建轴?
How do I create axes in Matlab for a non-current figure?
我可以在当前图形上创建一个新轴:
ax = gca;
% or
ax = axes;
如果我已经有了要使用的图的句柄,我可以将该图设置为当前图,然后然后创建坐标轴:
figure(h);
ax = axes;
但据我所知,如果不将其置于前台(并使其从其他 windows 窃取焦点),就无法在任意图形上创建轴?
是的,有:
ax = axes('Parent',h)
其中 h
是图形的句柄。
这利用了语法(参见documentation)
axes('PropertyName',propertyvalue,...)
: creates an axes object having the specified property values
设置创建的轴的'Parent'
属性。这样就可以在该图中创建轴,而无需将其聚焦。
我可以在当前图形上创建一个新轴:
ax = gca;
% or
ax = axes;
如果我已经有了要使用的图的句柄,我可以将该图设置为当前图,然后然后创建坐标轴:
figure(h);
ax = axes;
但据我所知,如果不将其置于前台(并使其从其他 windows 窃取焦点),就无法在任意图形上创建轴?
是的,有:
ax = axes('Parent',h)
其中 h
是图形的句柄。
这利用了语法(参见documentation)
axes('PropertyName',propertyvalue,...)
: creates an axes object having the specified property values
设置创建的轴的'Parent'
属性。这样就可以在该图中创建轴,而无需将其聚焦。