How to superimpose two figure, one to bottom right corner of larger.
조회 수: 6 (최근 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에서 Graphics Object Properties에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!