python的matplotlib怎样优雅地绘制向量?

现在需要绘制3D空间的几个向量,该怎么画啊?
类似这样的
图片描述

阅读 10.7k
1 个回答
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')

# Make the grid
x, y, z = np.meshgrid(np.array([1]),
                      np.array([1]),
                      np.array([1]))

# Make the direction data for the arrows
u = np.array([1, 0, 0])
v = np.array([0, 1, 0])
w = np.array([0, 0, 1])

ax.quiver(x, y, z, u, v, w, length=0.1, normalize=True)

plt.show()

参考这个 https://matplotlib.org/galler...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题