【发布时间】:2018-01-29 13:35:55
【问题描述】:
figure;
ax1 = axes;
figure;
ax2 = axes;
x = 0; y = 0;
while ishandle(ax1) && ishandle(ax2)
x = x + 1;
y = y + 1;
figure(1)
scatter(x,y, 'MarkerEdgeColor', 'red')
hold on
figure(2)
scatter(x,y, 'MarkerEdgeColor', 'blue')
hold on
end
在我的脚本中,我有多个图形,它们将循环更新。必须在脚本运行时显示数字。不幸的是,当前更新的图形总是在前台弹出,这使得无法监视某个图形。我知道figure(1) 和figure(2) 的调用会导致这种行为,但我怎样才能绘制这些数字,而不将窗口置于前台?
【问题讨论】:
-
您可以尝试
scatter(ax1, x,y, 'MarkerEdgeColor', 'red')指定应该使用的轴,而根本不调用figure。 -
哦,我没想到。完美运行,谢谢!我只是偶然发现了
set(0,'CurrentFigure',<handle of figure>),但你的想法可能会更好。 -
@mikkola 你应该回答这个问题,这是要走的路。
-
更好的方法是更新该行的
xdata和ydata属性。h=plot(0,0,...),然后在循环h.xdata = [h.xdata,x]内,对于 y 也是如此。这是最快的方法,如果你有很多点要绘制,将使用更少的内存。
标签: matlab matlab-figure