MATLAB: Four different figures of same plot – 3D plot, XZ, XY, YZ Plot

MATLABplot view 3d plot3 figure

Hi
I have a 3D plot and want to see all of the 2D views as separate figures. I know how to use the view command to see what I want (i.e. view([0 90])), but it just updates the current figure. I'd like to have four different figures of the same plot: one 3d, one a 2D XY view, one a 2D XZ view, and one a 2D YZ view. How can I open up new figures for each view?
Thanks!

Best Answer

You cannot have multiple figures with the same plot. Each plot can have only one parent. You can copyobj() the graphics into multiple figures and you can call view() on each of the resulting new axes, specifying the axes handle as the first argument.
For example,
curax = gca(); %what we are copying
views = [0 90 0; 90 0 0; 0 0 90];
titles = {'xy view', 'yz view', 'xz view'}; %you will need to fix these!
for extra_view = 1 : size(views,1)
newfig = figure();
newax = copyobj(curax, newfig);
view(newax, views(extra_view,:));
titles(newax, titles{extra_view});
set(newfig, 'Name', titles{extra_view});
end