我想知道是否有一种方法可以在 Python 中绘制数据立方体。我的意思是每个点都有三个坐标
x=part.points[:,0]
y=part.points[:,1]
z=part.points[:,2]
对于每个点我都有一个标量场 t(x,y,z)
我想绘制一个 3D 数据立方体,显示点的位置,并为每个点绘制与该点的标量场 t 成比例的颜色。
我尝试使用 histogramdd 但没有成功。
您可以使用绘图库 http://matplotlib.sourceforge.net/。
这里有一个工作示例(可以移动!):
import random
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
mypoints = []
for _ in range(100):
mypoints.append([random.random(), #x
random.random(), #y
random.random(), #z
random.randint(10,100)]) #scalar
data = zip(*mypoints) # use list(zip(*mypoints)) with py3k
fig = pyplot.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(data[0], data[1], data[2], c=data[3])
pyplot.show()
您可能必须自定义标量值与相应颜色的关系。
Matplotlib 的外观非常漂亮,但当您有很多点时,绘制和移动这些 3D 绘图的速度可能会很慢。在这些情况下我曾经使用过Gnuplot http://www.gnuplot.info/受控制于gnuplot.py http://gnuplot-py.sourceforge.net/。 Gnuplot也可以直接用作子进程,如图所示here https://stackoverflow.com/questions/2161932/calling-gnuplot-from-python and here http://linuxgazette.net/114/andreasen.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)