3D density plot - multiple isosurfaces on the same plot
Ältere Kommentare anzeigen
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?
1 Kommentar
Thomas
am 3 Jan. 2014
Akzeptierte Antwort
Weitere Antworten (2)
Mechrod
am 30 Jun. 2017
1 Stimme
Hi!
Instead of choosing the 'Facecolor', can Matlab use the values of the isosurfaces being plotted and create a colorbar based on this values?
R4pha3L
am 27 Feb. 2017
Bearbeitet: Walter Roberson
am 27 Feb. 2017
To understand better how the input data works I've put together this small script:
%Isosurface test sript
clear all
close all
clc
x=1:3
y=1:5
z=1:4
[X,Y,Z]=meshgrid(x,y,z)
D = sqrt(X.^2+Y.^2+Z.^2)
max(D(:))
min(D(:))
figure
isovalue = 0.2*(max(D(:))-min(D(:)))+min(D(:))
surf1 = isosurface(X,Y,Z,D,isovalue)
p1 = patch(surf1);
isonormals(x,y,z,D,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);
camlight; lighting gouraud
isovalue = 0.4*(max(D(:))-min(D(:)))+min(D(:))
surf2=isosurface(x,y,z,D,isovalue);
p2 = patch(surf2);
isonormals(x,y,z,D,p2);
set(p2,'FaceColor','yellow','EdgeColor','none','FaceAlpha',0.2);
isovalue = 0.6*(max(D(:))-min(D(:)))+min(D(:))
surf3=isosurface(x,y,z,D,isovalue);
p3 = patch(surf3);
isonormals(x,y,z,D,p3);
set(p3,'FaceColor','cyan','EdgeColor','none','FaceAlpha',0.3);
isovalue = 0.8*(max(D(:))-min(D(:)))+min(D(:))
surf4=isosurface(x,y,z,D,isovalue);
p4 = patch(surf4);
isonormals(x,y,z,D,p4);
set(p4,'FaceColor','blue','EdgeColor','none','FaceAlpha',1);
%----------
The big differece in using isosurface() is that the input data has to be length(x) by length(y) by length(z) (in the example above 5x3x4 matrix) and even the density data has to have this format for it to work.
Hope this helps ;)
Kategorien
Mehr zu Volume Visualization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

