MATLAB: 3D density plot – multiple isosurfaces on the same plot

3d density4d arrayisosurfacemulti-dimensional plot

Greetings,
I am struggling to plot a 4D array (density at 3D space) and produce a plot like the attached image.
Actually it does not necessarily have to look like the attachment but it must present the data in a clear way. For that purpose I tried to use scatter3 and isosurface without any success. I am not sure if these functions are the right ones. Regarding scatter3(X,Y,Z,S), my problem is that S must be a vector of the same length as X,Y,Z, whereas I want it to be an size(X)*size(Y)*size(Z) array that contains the density values. On the other hand, I managed to draw a surface using:
p = patch(isosurface(x,y,z,density,2))
isonormals(x,y,z,density,p)
set(p,'FaceColor','blue','EdgeColor','none');
daspect([1,1,1])
view(3); axis tight
camlight
lighting gouraud
The produced plot looks like this:
Yet I didn't find how to draw multiple surfaces with increasing isovalue into the same plot and make them transparent. Is this possible in Matlab? If not is there any other function to plot a 4D array?

Best Answer

I found it. This how I did the attached image:
figure
quantum=max(nfe)/8;
isovalue=6*quantum;
surf1=isosurface(x,y,z,normalized_Free_Energy_map,isovalue);
p1 = patch(surf1);
isonormals(x,y,z,normalized_Free_Energy_map,p1);
set(p1,'FaceColor','red','EdgeColor','none','FaceAlpha',0.1); % set the color, mesh and transparency level of the surface
daspect([1,1,1])
view(3); axis tight
camlight; lighting gouraud
isovalue=4*quantum;
surf2=isosurface(x,y,z,normalized_Free_Energy_map,isovalue);
p2 = patch(surf2);
isonormals(x,y,z,normalized_Free_Energy_map,p2);
set(p2,'FaceColor','yellow','EdgeColor','none','FaceAlpha',0.2);
isovalue=2*quantum;
surf3=isosurface(x,y,z,normalized_Free_Energy_map,isovalue);
p3 = patch(surf3);
isonormals(x,y,z,normalized_Free_Energy_map,p3);
set(p3,'FaceColor','cyan','EdgeColor','none','FaceAlpha',0.3);
isovalue=quantum;
surf4=isosurface(x,y,z,normalized_Free_Energy_map,isovalue);
p4 = patch(surf4);
isonormals(x,y,z,normalized_Free_Energy_map,p4);
set(p4,'FaceColor','blue','EdgeColor','none','FaceAlpha',1);
Related Question