【发布时间】:2016-07-05 04:03:30
【问题描述】:
这是我从下面的代码中得到的情节:
aa = np.zeros(len(self.depthrange))
bb = np.zeros(len(self.depthrange))
for i in range(0, self.n):
goodin = ~np.isnan(self.u[:, i])
bb[i] = self.u[goodin, i].mean()
aa[i] = self.v[goodin, i].mean()
speed = np.sqrt(bb**2 + aa**2)
dirt = np.arctan2(bb, aa) * 180 / np.pi
dirt[dirt < 360] += 360
dirt[dirt > 360] -= 360
binrange = -np.mean(self.variables.depth) + self.binrange[1, :]
aa = speed * np.cos(dirt * np.pi / 180)
bb = speed * np.sin(dirt * np.pi / 180)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.quiver(0, 0, binrange, aa, bb, np.zeros(len(bb)), pivot='tail', arrow_length_ratio=0.3, length=0.15, color='tomato', lw='2')
ax.text(0, -0.025, -15, 'W', color='k', fontsize=15)
ax.text(-0.025, 0, -15, 'S', color='k', fontsize=15)
ax.text(0.025, 0, -15, 'N', color='k', fontsize=15)
ax.text(0, 0.025, -15, 'E', color='k', fontsize=15)
ax.set_zlim(-15, 0)
ax.set_xlim(-0.25, 0.25)
ax.set_ylim(-0.25, 0.25)
plt.gca().invert_xaxis()
#plt.gca().invert_yaxis()
ax.view_init(elev=18, azim=30)
ax.dist = 8
ax.set_xlabel('m/s')
ax.set_ylabel('m/s')
ax.set_zlabel('Depth (m)')
ax.set_title('Mean Current Vector')
ax.plot([0, 0], [0, 0], zs=[-15, 0], lw=2, color='grey')
for i in range(0, self.n):
ax.plot([-0.1*0.25, 0.1*0.25], [0, 0], zs=[binrange[i], binrange[i]], lw=2, color='grey')
ax.plot([0, 0], [-0.1*0.25, 0.1*0.25], zs=[binrange[i], binrange[i]], lw=2, color='grey')
plt.show()
存在箭头,因为您可以看到线的颜色有所不同,但它们看起来不像箭头,有人知道我如何让箭头正确显示吗?
非常感谢,
【问题讨论】:
-
显示生成您在该函数中使用的数据的其余代码。很难从图像中复制它。此外,我在您显示的代码行中没有看到任何说明箭头是灰色的或者应该出现带有基点的文本。我的猜测是您犯了一个错误,这不一定是您共享的代码部分。
标签: python vector matplotlib 3d