필터 지우기
필터 지우기

3D density plot - multiple isosurfaces on the same plot

조회 수: 35 (최근 30일)
Thomas
Thomas 2013년 12월 29일
편집: Adam Danz 2020년 9월 4일
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
Thomas
Thomas 2014년 1월 3일
This is hte best I could get with scatter3(X,Y,Z,S,'r','*'):
It is not obvious where the high density regions reside.
If anyone know how to create the first image using isosurface please give me some hints!

댓글을 달려면 로그인하십시오.

채택된 답변

Thomas
Thomas 2014년 1월 5일
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);
  댓글 수: 4
Sakiru Badmos
Sakiru Badmos 2017년 2월 7일
편집: Sakiru Badmos 2017년 2월 7일
Hi Thomas, I am having problem plotting my density data in the form of an isosurface. I have x,y,z and density data at each coordinate. I have tried isosurface function in Matlab but I got error as my density is a vector and not a matrix. Kindly help me out as I don't understand the input to your code. Is your normalized_free_energy_map a matrix or vector? What does quantum represent? Thank you
Pavlo Kliuiev
Pavlo Kliuiev 2018년 3월 15일
thanks a lot! nice job!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Mechrod
Mechrod 2017년 6월 30일
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
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 ;)

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by