How to superimpose two figure, one to bottom right corner of larger.
3 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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 件のコメント
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 Exchange で Specifying Target for Graphics Output についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!