我之前发布了一个程序,我试图在 3d 散点图上绘制四维数据(xyz 坐标和电压),其颜色图取决于电压的大小。
我能够毫无错误地运行我的程序(表明我没有丢失任何包),尽管我的数据点总是显示为蓝色,这表明颜色映射没有正确应用。任何人都可以看到问题是什么?如果是这样,我将非常感激。
from pylab import *
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
x = array([-4,-4, -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,4,4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, -6.5, -6, -5.5,
])
y = array([-0.1, 3.95, 5.8,4.4,0.1,-4,-5.8,-4,1,2.4,3.2, 1.6,-0.8,-2.6,-3.3,-1.4,-0.1,3.95, 5.8,4.4,0.1,-4,-5.8,-4,1,2.4, 3.2, 1.6, -0.8, -2.6, -3.3, -1.4, -0.1, 3.95, 5.8, 4.4, 0.1, -4, -5.8, -4, 1, 2.4, 3.2, 1.6, -0.8, -2.6, -3.3, -1.4, -0.1, 3.95, 5.8, 4.4, 0.1, -4, -5.8, -4, 1, 2.4, 3.2, 1.6, -0.8, -2.6, -3.3, -1.4, -0.1, 3.95, 5.8, 4.4, 0.1, -4, -5.8, -4, 1, 2.4, 3.2, 1.6, -0.8, -2.6, -3.3, -1.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
])
z = array([5.85, 4, 0.2,-3.8,-5.85,-4.1,-0.15,4,2.75,1.4,-0.3, -2.6, -2.75,-2.7, 1.2, 3.2,5.85,4, 0.2,-3.8,-5.85,-4.1,-0.15, 4, 2.75, 1.4, -0.3, -2.6, -2.75, -2.7, 1.2, 3.2, 5.85, 4, 0.2, -3.8, -5.85, -4.1, -0.15, 4, 2.75, 1.4, -0.3, -2.6, -2.75, -2.7, 1.2, 3.2, 5.85, 4, 0.2, -3.8, -5.85, -4.1, -0.15, 4, 2.75, 1.4, -0.3, -2.6, -2.75, -2.7, 1.2, 3.2, 5.85, 4, 0.2, -3.8, -5.85, -4.1, -0.15, 4, 2.75, 1.4, -0.3, -2.6, -2.75, -2.7, 1.2, 3.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
])
v = array([0.29, 0.32, 0.3, 0.27, 0.3, 0.28, 0.31, 0.28, 0.19, 0.18, 0.19, 0.18, 0.19, 0.19, 0.2, 0.19, 0.12, 0.12, 0.11, 0.1, 0.11, 0.15, 0.14, 0.13, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.32, 0.31, 0.3, 0.31, 0.29, 0.3, 0.32, 0.31, 0.2, 0.21, 0.19, 0.19, 0.19, 0.19, 0.19, 0.2, 0.13, 0.12, 0.14, 0.14, 0.17, 0.17, 0.16, 0.14, 0.18, 0.18, 0.18, 0.19, 0.19, 0.19, 0.19, 0.18, 0.16, 0.18, 0.2, 0.19, 0.18, 0.15, 0.16, 0.18, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.18, 0.18, 0.13, 0.14, 0.15, 0.16, 0.17, 0.17, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.17, 0.17, 0.16, 0.15, 0.14, 0.12, 0.08, 0.09, 0.11, 0.09, 0.1, 0.11,
])
c = abs(v)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
cmhot = plt.get_cmap("hot")
cax = ax.scatter(x, y, z, v, s=50, c = c, cmap = cmhot)
plt.show()
非常感谢任何愿意为我看看这个的人。