如何将两个图形文件合并为一个文件 [英] How to merge two figure files into a single file

查看:122
本文介绍了如何将两个图形文件合并为一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对于一个简单的解决方案应该是个问题,但是我仍然找不到.

This should be a problem with a trivial solution, but still I wasn't able to find one.

假设我有2个matlab图形fig1.figfig2.fig,要在同一绘图窗口中加载并显示它们.

Say that I have 2 matlab figures fig1.fig, fig2.fig which I want to load and show in the same plotting window.

我该怎么办?

我的意思是,我非常确定我可以使用一些较低级别的图形命令来完成该任务,该命令从一个图像中提取内容并将其放入第二个图像中,但是我不敢相信没有任何高级别的内容我想说,执行此功能的函数(load fig2 on top of fig1)...比较2个图(不幸的是已经保存)是非常常见的任务.

I mean, I am pretty sure that I can accomplish the task using some low(er) level graphic command which extracts contents from one image and put them in the second one, nonetheless I cannot believe that there is not any high level function (load fig2 on top of fig1) that does this...Comparing 2 plots (unfortunately already saved) is a very common task, I'd say.

推荐答案

不清楚是要从图形中提取数据并比较数据,还是要将两个图形中的图合并为一个图形,这尚不清楚.

Its not clear if you want to extract data from the figures and compare the data, or if you want to combine the plots from two figures into a single figure.

这是将两个图形组合成一个图形的方式(如果您要这样做的话).

Here is how you combine two figures into one (if thats what you want to do)..

首先加载数字:

fig1 = open('FigureFile1.fig');
fig2 = open('FigureFile2.fig');

从图中获取轴对象

ax1 = get(fig1, 'Children');
ax2 = get(fig2, 'Children');

现在将hangle图形对象从ax2复制到ax1. 如果您的图形只有一个轴,则不需要循环

Now copy the hangle graphics objects from ax2 to ax1. The loop isn't neccesary if your figures only have a single axes

for i = 1 : numel(ax2) 
   ax2Children = get(ax2(i),'Children');
   copyobj(ax2Children, ax1(i));
end

注意该示例假定您的图形具有相同的坐标轴,并且要将对象从第二个图形的第一个轴复制到第一个图形的第一个轴.如果轴索引未对齐,则由您自己确定合适的索引.

Note This example assumes that your figures have the same nubmer of axes and that you want to copy objects from the first axes in the second figure to the first axes on the first figure. Its up to you to figure out the proper indexing if the axes indices aren't lined up.

这篇关于如何将两个图形文件合并为一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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