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

4 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

G A
G A el 3 de Jul. de 2021
Editada: G A el 3 de Jul. de 2021
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 comentarios
Jeffrey Gifford
Jeffrey Gifford el 6 de Jul. de 2021
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 el 6 de Jul. de 2021
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by