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

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

阅读 10.8k
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...

推荐问题