Matlab更新子图并保持 [英] Matlab updating subplots and hold on

查看:102
本文介绍了Matlab更新子图并保持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在更新子图时遇到麻烦.我将问题归结为以下示例:

I am having trouble with updating subplots. I've boiled my problem down to the following example:

win = figure(1);
win.sub1 = subplot(2, 2, 1);
win.sub2 = subplot(2, 2, 2);
win.sub3 = subplot(2, 2, 3);
win.sub4 = subplot(2, 2, 4);

x = 1:1:10;

plot(win.sub2, x, x); %graphs the line y = x in the second subplot, good.
hold on;
plot(win.sub2, x, -x) %ought to plot line y = -x over line y = x, but does not.

执行第二个绘图时,尽管保持按住状态,第一个绘图仍会消失.看起来唯一可行的方法是使用axes(win.sub2),但我试图避免这种情况,因为这确实减慢了我的程序的速度(在一个图形上绘制4个子图,每个子图都有大约2个重叠的图,以创建1000帧以上的影片).感谢您的协助.谢谢

When executing the second plot, the first plot disappears despite the hold on. The only thing that seems to make this work is if I use axes(win.sub2), but I'm trying to avoid that because it really slows down my program (plotting 4 subgraphs on one figure, each with about 2 overlaid plots, to create a 1000+ frame movie). I appreciate any assistance. Thanks

推荐答案

为什么您的示例无法按预期运行,但将hold on;更改为hold(win.sub2, 'on');似乎会产生预期的结果,我感到有些困惑.

I am a bit puzzled why your example does not work as expected, but changing hold on; to hold(win.sub2, 'on'); seems to produce the desired result.

注意:在执行示例代码时,matlab会向我发出警告,可能是因为第二行覆盖了第一行中定义的win.

Note: when executing your example code, matlab gives me a warning, probably because the second line overwrites win as defined in the first line.

这篇关于Matlab更新子图并保持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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