Matlab Openfig到现有图 [英] Matlab openfig to existing figure

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

问题描述

在Matlab中,当我使用openfig(filename);打开保存的图形时,它将始终打开一个新窗口.当'reuse'参数似乎已经打开时,所有的'reuse'参数都不会加载该文件.但是,我希望将文件打开为给定的图,并覆盖其内容.有没有办法将图形句柄传递给openfig,还是有另一个函数可以完成此任务?

When in Matlab I use openfig(filename); to open a saved figure, it always opens a new window. All the 'reuse' argument does is not load the file when it appears to already be open. However, I wish to open the file into a given figure, and just overwrite its contents. Is there a way to pass a figure handle to openfig, or is there another function that would accomplish this?

所以在代码中,我想做的事情大致如下:

So in code, what I would like to do is something along the following lines:

f = figure;
openfig(filename, 'Figure',f);

,然后该图形将显示在图形f中,而不是打开第二个图形窗口.

and then the figure would be displayed in figure f rather than having opened a second figure window.

推荐答案

我认为您可以使用

I think you can arrange something close to what you want with the copyobj function. Here is a try with a docked figure:

% --- Create sample figure
h = figure;
ezplot('sin(x)');
set(gcf, 'Windowstyle', 'docked');

pause

% --- Replace the axes
clf
g = openfig('test.fig', 'invisible');
copyobj(get(g, 'CurrentAxes'), h);
delete(g);

这使我可以平滑地替换轴,而不会出现图形闪烁的情况.

Which gives me a smooth replacement of the axes, without flickering of the figure.

但是,我不知道全屏显示的效果如何,它肯定取决于您选择的方法.还要详细检查copyobj的文档,它没有复制所有内容,因此您可能要使用legacy选项.

However, I don't know how this would behave with a fullscreen figure, it surely depends on the method you choose. Check also the doc of copyobj in detail, it's not copying everything so you may want to use the legacy option.

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

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