3D density plot - multiple isosurfaces on the same 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?
采纳的回答
更多回答(2 个)
Mechrod
2017-6-30
1 个投票
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
2017-2-27
编辑:Walter Roberson
2017-2-27
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 ;)
类别
在 帮助中心 和 File Exchange 中查找有关 Volume Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

