www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/CombineTwoAxesIntoSubplotsInSingleFigureExample.m
%% Combine Two Axes Into Subplots In Single Figure % Copyright 2015 The MathWorks, Inc. %% Part 1 x = linspace(0,10); y1 = sin(x); figure plot(x,y1) ax1 = gca; y2 = 2*sin(x); figure plot(x,y2) leg = legend('2*Sin(x)'); ax2 = gca; %% Part 2 f3 = figure; ax1_copy = copyobj(ax1,f3); subplot(2,1,1,ax1_copy) copies = copyobj([ax2,leg],f3); ax2_copy = copies(1); subplot(2,1,2,ax2_copy)