# How to use existing plots in a new plot?

13 visualizaciones (últimos 30 días)
RFR el 21 de Ag. de 2018
Respondida: Julie el 21 de Ag. de 2018
I am trying to use three existing plots to make a new plot. I also want to resize the original plots and organise them with the following dimensions:
figure;
pos1= [0.1, 0.1, 0.2, 0.6];
subplot('Position',pos1)
pos2= [0.35, 0.75, 0.6, 0.20];
subplot('Position',pos2)
pos3= [0.35, 0.1, 0.6, 0.60];
subplot('Position',pos3)
I have tried with the copyobj function but I cannot make it work. I would appreciate if you guys can help me to solve this problem. What I have is:
%create a figure
figure;
surf(peaks)
%get axes
ax1=gca;
%create a new figure
fnew=figure(2);
%copy first figure
ax1_copy = copyobj(ax1,f4);
subplot(2,2,2,ax1_copy)
%copy second figure
ax2_copy = copyobj(ax1,f4);
subplot(2,2,3,ax2_copy)
%copy third figure
ax3_copy = copyobj(ax1,f4);
subplot(2,2,4,ax3_copy)
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Adam Danz el 21 de Ag. de 2018
Describe what is wrong with the outcome of your approach.

Iniciar sesión para comentar.

### Respuestas (2)

Adam Danz el 21 de Ag. de 2018
First, store the handles to your figure and axes like this.
f1 = figure;
pos1= [0.1, 0.1, 0.2, 0.6];
sp1 = subplot('Position',pos1);
pos2= [0.35, 0.75, 0.6, 0.20];
sp2 = subplot('Position',pos2);
pos3= [0.35, 0.1, 0.6, 0.60];
sp3 = subplot('Position',pos3);
After you're done plotting, copy content from figure 1 to figure 2. You must enter the handles to each axis and the handle to the new figure.
f2 = figure;
cloneHand = copyobj([sp1, sp2, sp3], f2);
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Julie el 21 de Ag. de 2018
It's a bit of a workaround, but if copyobj failed you can just read the data off of the existing plots using THIS METHOD. Then re-plot in the subplot structure.
Alternatively you may be using copyobj incorrectly angd you can try using THIS METHOD
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Axis Labels en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by