我有一个如下所示的数据集:
Intensity = ( [1, 2, 3, 4], [6, 7, 9, 10] )
Xposition = (0.1, 0.2, 0.3, 0.4)
Yposition = (1E^-9, 1.2E^-9)
因此,对于每个Yposition
,我们在Intensity
中存储了一个1D数组,对应于每个Xposition
。
现在我想在Z上绘制Xposition
(X轴),Yposition
(Y轴)和Intensity
来生成3D图。我怎么能用matplotlib做到这一点?
答案 0 :(得分:0)
matplotlib页面上有很好的tutorials。查看two examples并略微调整代码:
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = (0.1,0.2,0.3,0.4)
y = (10**-9, 1.2*10**-9)
x,y = np.meshgrid(x,y)
z = ( [1,2,3,4], [6,7,9,10] )
ax.scatter(x, y, z)
plt.show()