【问题标题】:Combine figures with subplots into one figure将图形与子图合并为一个图形
【发布时间】:2017-09-27 10:56:46
【问题描述】:

在集群上进行了多次模拟,每次模拟保存一个图形,我想将这些图形组合成一个图形。

为方便起见,假设我们有两个数字:

x = 0:0.01:.2;

subplot(1,3,1)
plot(x,sin(x))
legend('sin(x)')

subplot(1,3,2)
plot(x,cos(x))
legend('cos(x)')

subplot(1,3,3)
plot(x,tan(x))
legend('tan(x)')

x = 0:0.01:.2;

subplot(1,3,1)
plot(x,x,'r')
legend('x')

subplot(1,3,2)
plot(x,1-x.^2/2,'r')
legend('1-x.^2/2')

subplot(1,3,3)
plot(x,x,'r')
legend('x')

另存为figure1.figfigure2.fig。我现在想将这两个图组合成一个带有 3 个子图、相同颜色和图例的图形。有没有简单的方法可以做到这一点?

【问题讨论】:

    标签: matlab plot matlab-figure subplot


    【解决方案1】:

    Open both the figurescopy the objects 一个数字到另一个。

    hf1 = openfig('figure1.fig');
    hf2 = openfig('figure2.fig');    set(hf2, 'Visible', 'off'); 
    
    for k=1:numel(hf1.Children)
        copyobj(hf2.Children(k).Children, hf1.Children(k));  %Copying objects to figure1
    end
    

    提供的样本数据的结果是:


    由于提供的样本数据本身,这些图可能过于相似而无法注意到。

    【讨论】:

      【解决方案2】:

      从图形菜单文件->生成代码...,您可以生成代码来创建图形。然后你可以根据需要修改它(子图索引和位置)与另一个图结合。

      我没有找到生成代码的命令。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-18
        • 2019-04-09
        • 1970-01-01
        • 1970-01-01
        • 2014-04-26
        • 1970-01-01
        • 2014-12-14
        • 1970-01-01
        相关资源
        最近更新 更多