How to superimpose two figure, one to bottom right corner of larger.

3 ビュー (過去 30 日間)
Jeffrey Gifford
Jeffrey Gifford 2021 年 7 月 2 日
コメント済み: G A 2021 年 7 月 6 日
Hello,
Figure 1 works as a visual representaion of a legend for the calculations used to produce Figure 2. I am trying to put Figure 1 in the bottom right corner of Figure 2. Is there a way to reduce the size of Figure 1 and to locate it in the lower right region of Figure 2?

採用された回答

G A
G A 2021 年 7 月 3 日
編集済み: G A 2021 年 7 月 3 日
fig1 = figure(1); % create figure1
pos1 = fig1.Position; % position of figure1: pos1 = [x1, y1, width1, hight1]
pos2 = pos1;
pos2(3) = pos1(3)/4; % width2
pos2(1) = pos1(1) + pos1(3) - pos2(3); % x2
pos2(4) = pos1(4)/4; % hight2
fig2 = figure(2); % create figure2
fig2.Position = pos2; % position of figure2 - in the right bottom corner
Or may be you need an inset?
https://uk.mathworks.com/matlabcentral/answers/60376-how-to-make-an-inset-of-matlab-figure-inside-the-figure
x=-2*pi:0.1:2*pi;
y=sin(x);
fig3 = figure(3);
clf
hold on
plot(x,y,'-r');
axes('Position',[.7 .12 .2 .2])
box on
plot(x,y,'-b');
hold off
  2 件のコメント
Jeffrey Gifford
Jeffrey Gifford 2021 年 7 月 6 日
Hi, the code seems to run but nothing is being displayed. I used the first set of code you provided and removed the semicolin on the last line but that only displays the properties.
Any suggestions?
G A
G A 2021 年 7 月 6 日
If you need plots, then you can plot in figure watever you wish.
x = -2*pi:0.1:2*pi;
y1 = sin(x);
y2 = cos(x);
fig1 = figure(1); % create figure1
clf
p1 = plot(x,y1,'b'); % plot sine in figure(1)
grid on
% get the position of the figure(1) and use it to define the position of
% the figure(2)
pos1 = fig1.Position; % position of figure1: pos1 = [X1, Y1, width1, hight1]
pos2 = pos1;
pos2(3) = pos1(3)/4; % width2 = width1/4
pos2(1) = pos1(1) + pos1(3) - pos2(3); % X2 coordinate of the position2 is moved to the right
pos2(4) = pos1(4)/4; % hight2 = hight1/4
fig2 = figure(2); % create figure2
clf
fig2.Position = pos2; % position of figure2 - in the right bottom corner
p2 = plot(x,y2,'r'); % plod cosine in figure(2)
grid on

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by