How to plot 3d data with values associated at each point?

조회 수: 10 (최근 30일)
Sergi
Sergi 2014년 5월 5일
댓글: Walter Roberson 2020년 4월 11일
I have a list of nodes (3 coordinate points for each one). I also have associated a value at each node. How can I represent a 3d plot of all the nodes, colored with the value associated?
For example:
if true
1.35846579 -0.010903161 -1.35846579 -2.466e-05
2.71686196 -0.033203464 -2.71686196 -4.506e-05
4.07514048 -0.066900126 -4.07514048 -6.485e-05
5.43325424 -0.111991957 -5.43325424 -8.391e-05
6.79115438 -0.168477371 -6.79115438 -0.000102
end
Where the first 3 columns are X,Y,Z coordinates of the points, and last column is the value associated that i want to represent.
Thank you very much

답변 (1개)

Star Strider
Star Strider 2014년 5월 5일
This is not as neat or efficient as I would like it to be, but it works:
s = [1.35846579 -0.010903161 -1.35846579 -2.466e-05
2.71686196 -0.033203464 -2.71686196 -4.506e-05
4.07514048 -0.066900126 -4.07514048 -6.485e-05
5.43325424 -0.111991957 -5.43325424 -8.391e-05
6.79115438 -0.168477371 -6.79115438 -0.000102];
cr = colormap(jet);
s1 = (abs(s(:,4)/max(s(:,4))));
s2 = ceil(s1*63/max(s1))
mc = cr(s2,:)
figure(1)
hold on
for k1 = 1:size(s,1)
stem3(s(k1,1), s(k1,2), s(k1,3), 'fill', 'MarkerFaceColor', mc(k1,:))
end
hold off
grid on
view(-30, 30)
I used a stem3 plot because it’s easier to see the relative positions of the data. Experiment with it to get the result you want. This works with scatter3 as well.
  댓글 수: 5
Star Strider
Star Strider 2020년 4월 11일
Use the griddata function.
Walter Roberson
Walter Roberson 2020년 4월 11일
The last time I encountered data in 26 columns like that, it was information about molecules, and included information about which atoms were linked to which other atoms. Would that happen to be the kind of information you have?
Does your data represent a set of points sampled from a volume, and your goal is to interpolate the data throughout the volume? If so then are you wanting to create a voxelized view, or are you wanting to draw isosurfaces?
Does your data represent a set of points on the surface of a convex object, and you want to build faces and edges? Data from a non-convex object that has holes but none-the-less there are distinct implied surfaces? Data from a point cloud that you would like to draw an outside boundary of?

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by