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

16 次查看(过去 30 天)
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 个评论
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