具有4D数据的3D散点图 [英] 3D scatter plot with 4D data
问题描述
我需要绘制一个3D图形,每个数据点都使用色图使用第4个变量的值进行着色.可以说我有4个变量X,Y,Z和W,其中W = f(X,Y,Z).我想要一个以X,Y和Z为三个轴的3D图.语句scatter3(X,Y,Z,'filled','b')
给了我3D的散点图,但我想通过将点表示为额外参数来将Z的值合并到图形中(可以使用不同的区域:对于Z值较高而较小的数据点,圆圈较大圈出Z值较低的数据点,或使用色图绘制具有不同颜色的数据点).但是,我是MATLAB的新手,真的不知道如何进行.任何帮助将不胜感激.
I need to plot a 3D figure with each data point colored with the value of a 4th variable using a colormap. Lets say I have 4 variables X,Y,Z and W where W = f(X,Y,Z). I want a 3D plot with X, Y, and Z as the three axis. The statement scatter3(X,Y,Z,'filled','b')
gives me a scatter plot in 3D but I want to incorporate the value of Z in the graph by representing the points as an extra parameter (either with different areas :bigger circles for data points with high value of Z and small circles for data points with low value of Z or by plotting the data points with different colors using a colormap). However, I am a novice in MATLAB and dont really know how to proceed. Any help will be highly appreciated.
提前谢谢!
推荐答案
因此,对于大小矢量(第4个输入)和颜色矢量(第5个输入)只需使用z
:
So just use z
for the size vector (4th input) as well as the color vector (5th input):
z = 10*(1:pi/50:10*pi);
y = z.*sin(z/10);
x = z.*cos(z/10);
figure(1)
scatter3(x,y,z,z,z)
view(45,10)
colorbar
大小向量必须大于0,因此您可能需要相应地调整z
.
The size vector needs to be greater 0, so you may need to adjust your z
accordingly.
这篇关于具有4D数据的3D散点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!