フィルターのクリア

plotting two figures side by side

476 ビュー (過去 30 日間)
Tri
Tri 2014 年 7 月 10 日
回答済み: Nate Roberts 2018 年 5 月 18 日
how do I plot two figures side by side?

採用された回答

Laurent
Laurent 2014 年 7 月 10 日
編集済み: Laurent 2014 年 7 月 10 日
You can use subplot. First create a figure
figure;
and then
subplot(1,2,1)
%make here your first plot
subplot(1,2,2)
%make here your second plot
More info:
  2 件のコメント
CaptCook
CaptCook 2015 年 12 月 23 日
Doesn't this create two "plots" side by side in the same "figure"? The question, which I am also asking, is whether there is any easy way to get 2 figures side by side? By default they seem to stack on top of each other.
Lydia Keppler
Lydia Keppler 2016 年 10 月 17 日
You can set the position of your figure with the following command: figure; set(gcf,'position',[20 50 1250 600])
Depending on the size of your screen, you might have to adjust the numbers, which indicate the position of the bottom and the left and the width and height of the figure. You can then set it so that the figures will be plotted next to each other.
Makes sense?

サインインしてコメントする。

その他の回答 (1 件)

Nate Roberts
Nate Roberts 2018 年 5 月 18 日
You can use the 'Position' information from gcf.
Here is an example:
close all
x = 0:0.01:60*pi;
figure(1);
plot(x,sin(x),'b'); xlim([0,2*pi]);
pos1 = get(gcf,'Position'); % get position of Figure(1)
set(gcf,'Position', pos1 - [pos1(3)/2,0,0,0]) % Shift position of Figure(1)
figure(2);
plot(x,cos(x),'r'); xlim([10*pi,60*pi]);
set(gcf,'Position', get(gcf,'Position') + [0,0,150,0]); % When Figure(2) is not the same size as Figure(1)
pos2 = get(gcf,'Position'); % get position of Figure(2)
set(gcf,'Position', pos2 + [pos1(3)/2,0,0,0]) % Shift position of Figure(2)
Which results in two figures side by side:

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by