按 Z 值着色的 3D 散点图
我已经用谷歌搜索了一段时间,但找不到解决我的问题的方法。我是一名业余 matlab 用户,我想创建一个 3D 散点图,为此我有一个包含 3D 空间中多个点的矩阵:
>> size(A)
ans =
2511 3
我能够使用“scatter3”函数创建 3D 散点图,但现在我有点卡住了对 3D 点进行颜色编码。
<块引用>scatter3(A(:,1),A(:,2),A(:,3));
这将绘制数据,但现在我想添加基于 z 值的颜色编码... 颜色本身并不重要。它可以是彩虹光谱或温度光谱或其他什么。我只是想对它们进行颜色编码以区分点的 z 值。
有人能帮我解决这个问题吗?谢谢你!
I've been googling for a while but couldn't find a solution for my problem. I am an amateur matlab user and I would like to create a 3D scatterplot, for this I have a matrix containing several points in 3D space:
>> size(A)
ans =
2511 3
I was able to create a 3D scatterplot using "scatter3" function, but now I am stuck a bit at color-coding the 3D points.
scatter3(A(:,1),A(:,2),A(:,3));
This will plot the data, but now I would like to add a color coding based on the z-Value...
The colors themself don't matter too much. It could be a rainbow spectrum or a temperature spectrum or whatever. I just would like to colorcode them to distinguish the z-Values of the points.
Can anybody help me with this? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须为 scatter3 提供更多参数。
S
允许您为每个标记(使用矢量)指定区域或为所有标记指定单个区域,而C
允许您指定颜色。如果C
是一个向量,它的值将线性映射到当前的颜色图。例如,要更改颜色图,请调用colormap(jet)
。请参阅有关颜色图
的文档。抱歉,如果这令人困惑。简短版本:
You have to give some more arguments to
scatter3
.S
lets you specify areas for each markers (with a vector) or a single area for all the markers, whileC
lets you specify color. IfC
is a vector, its values will be linearly mapped to the current colormap. To change the colormap, callcolormap(jet)
for example. See the documentation oncolormap
.Sorry if that's confusing. Short version: