简体   繁体   English

Python-为3D线图着色

[英]Python - color a 3d line plot

I have a 3d line plot of the solar spectrum, which I plotted using the command, 我有一个太阳光谱的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')

The resultant plot is solid blue and takes whichever individual color I give in the function: plot( ). 生成的图为纯蓝色,并采用我在函数中给出的任意一种颜色:plot()。

I have been trying to create a color gradient along the z-axis, intensity, without any success. 我一直在尝试沿z轴创建颜色渐变强度,但没有成功。

I have around 500 test numbers, each has 744 data points. 我大约有500个测试编号,每个测试编号都有744个数据点。

Thank you for the help! 感谢您的帮助!

This wouldn't let me post images because I don't have enough reputation. 这不会让我发布图片,因为我的信誉不足。 Anyway, here's the link to the plot I get using this code https://plus.google.com/106871046257785761571/posts/fMYsDF5wAQa 无论如何,这是我使用此代码得到的地块的链接https://plus.google.com/106871046257785761571571/posts/fMYsDF5wAQa

在此处输入图片说明

Using the example - 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 使用示例-python matplotlib.pyplot中3D参数曲线的线颜色 -我得到了沿z轴具有颜色渐变的散点图-这是该图的图像的链接-https: //plus.google.com/u / 0/106871046257785761571 /帖/ SHTsntgQxTw?PID = 6133159284332945618&OID = 106871046257785761571

在此处输入图片说明

I used the following command: 我使用以下命令:

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()

I am still working on getting a colored line plot because I have a lot of points, which makes scatter plot very slow to work with. 我仍然在获取彩色线图,因为我有很多要点,这使得散点图的处理非常缓慢。

Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM