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

조회 수: 19 (최근 30일)
Thomas
Thomas 2012년 2월 19일
편집: Haozhe Wang 2021년 11월 10일
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
  댓글 수: 1
Haozhe Wang
Haozhe Wang 2021년 11월 10일
편집: Haozhe Wang 2021년 11월 10일
The second solution works perfect, even for some complex 3d plots, thank you!

댓글을 달려면 로그인하십시오.

카테고리

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