Python - 为 3d 线图着色

Python - color a 3d line plot

我有一个太阳光谱的 3d 线图,我使用命令绘制的,

from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.collections import PolyCollection, LineCollection
from matplotlib.colors import colorConverter, ListedColormap, BoundaryNorm
import matplotlib.cm as cm

fig = plt.figure(figsize(15, 8))
ax = fig.gca(projection='3d')

x = SpectrumDF['Wavelength']
z = SpectrumDF['DNI']
y = SpectrumDF['TESTNUM']

ax.plot(x, y, z)
ax.set_xlabel('Wavelength')
ax.set_ylabel('Test Number')
ax.set_zlabel('Intensity')

结果图为纯蓝色,采用我在函数 plot( ) 中给出的任何一种颜色。

我一直在尝试沿 z 轴强度创建颜色渐变,但没有成功。

我有大约 500 个测试编号,每个测试编号有 744 个数据点。

感谢您的帮助!

这不会让我 post 图片,因为我没有足够的声誉。无论如何,这是我使用此代码 https://plus.google.com/106871046257785761571/posts/fMYsDF5wAQa

得到的情节的 link

使用示例 - Line colour of 3D parametric curve in python's matplotlib.pyplot - I got a scatter plot with color gradient along the z axis - here's the link to the image of that plot - https://plus.google.com/u/0/106871046257785761571/posts/SHTsntgQxTw?pid=6133159284332945618&oid=106871046257785761571

我使用了以下命令:

fig = plt.figure(figsize(15,8))
ax = fig.gca(projection='3d')

x = FilteredDF['Wavelength']
z = FilteredDF['DNI']
y = FilteredDF['TESTNUM']

ax.scatter(x, y, z, c=plt.cm.jet(z/max(z)))

ax.set_xlabel('Wavelength')
ax.set_ylabel('Test Number')
ax.set_zlabel('Intensity')

plt.show()

我仍在努力获得彩色线图,因为我有很多点,这使得散点图的处理速度非常慢。

谢谢