按 Z 值着色的 3D 散点图

发布于 2024-12-17 04:41:28 字数 437 浏览 5 评论 0原文

我已经用谷歌搜索了一段时间,但找不到解决我的问题的方法。我是一名业余 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一百个冬季 2024-12-24 04:41:28

您必须为 scatter3 提供更多参数。

scatter3(X,Y,Z,S,C);

S 允许您为每个标记(使用矢量)指定区域或为所有标记指定单个区域,而 C 允许您指定颜色。如果C是一个向量,它的值将线性映射到当前的颜色图。例如,要更改颜色图,请调用colormap(jet)。请参阅有关颜色图的文档。

抱歉,如果这令人困惑。简短版本:

scatter3(A(:,1),A(:,2),A(:,3),9,A(:,3));
colormap(jet); %# or other colormap

You have to give some more arguments to scatter3.

scatter3(X,Y,Z,S,C);

S lets you specify areas for each markers (with a vector) or a single area for all the markers, while C lets you specify color. If C is a vector, its values will be linearly mapped to the current colormap. To change the colormap, call colormap(jet) for example. See the documentation on colormap.

Sorry if that's confusing. Short version:

scatter3(A(:,1),A(:,2),A(:,3),9,A(:,3));
colormap(jet); %# or other colormap
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文