How to merge 3d plots of level planes into one plot (graph)
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
0 Kommentare
Antworten (1)
Patrick Kalita
am 27 Feb. 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 Kommentar
Haozhe Wang
am 10 Nov. 2021
Bearbeitet: Haozhe Wang
am 10 Nov. 2021
The second solution works perfect, even for some complex 3d plots, thank you!
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!