Is it possible to show two .fig files in the same figure?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear All,
I am able to display two .fig files in the same figure as in the code below (like hold on function). However, I'm pretty sure I'm doing something wrong. Because, instead of one, two figures are opened. Also, I can't set the axis limits in any way.
openfig('try1.fig');
fig = gcf;
openfig('try2.fig');
hAxes = findobj(fig, 'Type', 'axes');
copyobj(allchild(gca), hAxes);
Any thoughts?
0 comentarios
Respuestas (2)
Walter Roberson
el 10 de Jun. de 2023
figures are the top-level documented visible graphics objects. .fig files represent figures. It is not possible to display two .fig files in one figure. You can take the graphics contents of two distinct figures and copy the contents to a common figure; @Matt J's approach using copyobj() is good for that purpose.
But a figure is a graphical object combined with behaviour and if you had two figures with different behaviours and tried to combine them, you would have problems. If one figure defined left mouse button press as zoom, but the second figure defined left mouse button press as starting to draw a line, then you cannot combine the two behaviours into one figure.
There is at least one undocumented or poorly documented graphics container that can have figures as children. If you invoke volumeViewer() then several figures are generated inside some kind of container. At one point I did a bit of tracking about the properties of that container, but I have forgotten the details now.
0 comentarios
Matt J
el 10 de Jun. de 2023
Editada: Matt J
el 10 de Jun. de 2023
I am able to display two .fig files in the same figure as in the code below (like hold on function).
When you use hold on/off, the plotting commands are not generating new figures. They are generating new child objects (lines, scatter, images) in the current axes. You would have to obtain the handles to the Children of the two different axes and parent them, or copies of them, to a 3rd axes. Example:
H1=figure;
plot(rand(1,5),'-rx'); title 'Plot 1'
H2=figure;
plot(rand(1,5),'--bo'); title 'Plot 2'
figure;
hAxes=axes;
h=findobj([H1,H2],'Type','Line');
copyobj(h,hAxes); title 'Copy Plot'
0 comentarios
Ver también
Categorías
Más información sobre Graphics Object Programming 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!