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

6 次查看(过去 30 天)
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!

回答(1 个)

Patrick Kalita
Patrick Kalita 2012-2-27
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

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by