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

8 ビュー (過去 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 Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by