Home > Net >  Matlab isosurface plots lose 3d when used with subplot
Matlab isosurface plots lose 3d when used with subplot

Time:06-23

I'm trying to plot a bunch of isosurface plots together with subplot, and I want them to appear 3d and be rotatable. However, I find that when I combine subplot with isosurface the plots appear 2d and are not rotatable. Here's a MRE:

[x,y,z] = meshgrid([-3:0.25:3]); 
V = x.*exp(-x.^2 -y.^2 -z.^2);

for i=1:4
    subplot(2,2,i);

    isosurface(x,y,z,V,1e-4);
end

How can I make this rotatable? If I plot only one isosurface, without subplot, then it's in 3d and rotatable. If I use subplot with surf, I get 4 rotatable 3d surface plots. What am I missing here?

CodePudding user response:

As explained enter image description here

figure
plot(1,1)
isosurface(x,y,z,V,1e-4);

enter image description here

A workaround for this is to force the conversion to a 3d Axis object with view(3)(plus re-adding camlight):

[x,y,z] = meshgrid([-3:0.25:3]); 
V = x.*exp(-x.^2 -y.^2 -z.^2);

figure;

for ii = 1:4

subplot(2,2,ii);
isosurface(x,y,z,V,1e-4);
view(3)
camlight;

end

enter image description here

  • Related