Effacer les filtres
Effacer les filtres

How to merge 3d plots of level planes into one plot (graph)

6 vues (au cours des 30 derniers jours)
Thomas
Thomas le 19 Fév 2012
Modifié(e) : Haozhe Wang le 10 Nov 2021
I'm attempting to merge 3d plots from a function in the file exchange named 'plotregion.m' I'm using this function to get cross section plots in 3d that are at a fixed 'z' value.
For example:
figure(1)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;50],[50;50;50])
figure(2)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;49],[50;50;49])
These commands will give me two separate figures each with the plot of plane in 3d. I want to merge these two plots.
I've looked into using
X = findobj(...)
copyobj(X,findobj(...))
I don't know how to used these commands.
In the end I will have a range of 'z' values for which I will obtain these plots and use a for loop to merge them all into one graph.
Any help would be greatly appreciated!

Réponses (1)

Patrick Kalita
Patrick Kalita le 27 Fév 2012
I'm not familiar with the plotregion.m function, but the first thing I would do is check to see if returns a graphics object handle. If it does then you can collect all those handles and set their Parent property as needed.
If the function doesn't return a handle, then the best solution will depend a lot on how plotregion is written. First I would just try this:
figure(1)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;50],[50;50;50])
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;49],[50;50;49])
If plotregion uses only low-level graphics commands (like patch and line), then that should work. It should keep adding objects to the same axes.
If plotregion uses high-level graphics commands that respect the hold state, then you could try this:
figure(1)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;50],[50;50;50])
hold on
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;49],[50;50;49])
If all else fails, you could probably try this:
figure(1)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;50],[50;50;50])
a1 = gca;
figure(2)
plotregion([-1 0 0;-1 -24 0],[0; 72],[-50;-50;49],[50;50;49])
a2 = gca;
objectsThatWereJustCreated = get(a2, 'Children');
set( objectsThatWereJustCreated, 'Parent', a1 ); % move them to the first axes
  1 commentaire
Haozhe Wang
Haozhe Wang le 10 Nov 2021
Modifié(e) : Haozhe Wang le 10 Nov 2021
The second solution works perfect, even for some complex 3d plots, thank you!

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by