我在Stack Overflow上发表了一篇帖子Python 3D plotting of measurement data。
当我尝试将标记代码的解决方案用于我的模拟器数据时,它会显示运行时错误。我的数据包含第一列astha,第二列phi和第三列作为dBi标度的指向性[从-200到5.583]。 模拟器直接提供theta,phi和方向性之间的网格数据集。 main.txt
RuntimeError:找不到toolkit null的traitsui.toolkits插件
我检查了Mayavi的安装,没关系,没有错误。我试着评论这个链接,但我没有足够的声誉来评论那里。
这是我的尝试。
# Clean up the data.
import csv
import numpy as np
from mayavi import mlab
with open('main.txt', newline='') as f:
reader = csv.reader(f)
header_line_1 = next(reader)
header_line_2 = next(reader)
data = [row[0].split() for row in reader]
data = np.array(data, dtype=np.float)
theta = np.unique(data[:,0]) # theta values are in degree with a interval of 5 degree.
phi = np.unique(data[:,1]) # phi values are in degree with a interval of 5 degree.
dir_dB = data[:,2] # Abs values of directivity on dBi scale.
r = dir_dB
phi, theta = np.mgrid[phi, theta]
x = r*np.sin(phi)*np.cos(theta)
y = r*np.sin(phi)*np.sin(theta)
z = r*np.cos(phi)
# ploting code
intensity = phi * theta
obj = mlab.mesh(x, y, z, scalars=intensity, colormap='jet')
obj.enable_contours = True
obj.contour.filled_contours = True
obj.contour.number_of_contours = 20
mlab.show()