如何根据第 4 个变量的数据为 scatter3 中的点着色?

How to color the dots in scatter3 based on data from 4th variable?

我有位于大脑内部通道的 3D 坐标 (x,y,z)。我正在使用 scatter3 函数将它们绘制在脑图上以获得下图(现在坐标不是真的,但现在没关系): 现在的颜色只是随机分配的,但我想根据第 4 个变量的数据为我的 scatter3 上的每个点着色。第 4 个变量包含有关在该通道中检测到的信号数量的信息。例如,我有 80 个具有 X、Y、Z 坐标 (80x3) 的通道和一个带有信号数量 (80x1) 的变量 N。如何根据 N 为我的 80 个通道着色?我想用附近的颜色条进行视觉解释 - 例如,点越暗,在该通道中检测到的信号数量就越高。

现在我只有这个:

scatter3(sw_chs_coords(:,2), sw_chs_coords(:,1), sw_chs_coords(:,3), []); 

xlabel('X')
ylabel('Y')
zlabel('Z')
hold on
view(0, 0)

你能帮我解决这个问题吗?

这听起来就像 scatter3

的第 5 个输入

scatter3(X,Y,Z,S,C) draws each circle with the color specified by C.

  • If C is a RGB triplet or character vector or string containing a color name, then all circles are plotted with the specified color.
  • If C is a three column matrix with the number of rows in C equal to the length of X, Y, and Z, then each row of C specifies an RGB color
    value for the corresponding circle.
  • If C is a vector with length equal to the length of X, Y, and Z, then the values in C are linearly mapped to the colors in the current colormap.

因此,您可以指定 RGB 值(即 [0 1] 中的 3x1 数组或正常 RGB 值的 x/256),或者您只提供另一个信息向量并将其设置为 colormap表示向量中的连续值。