为什么matplotlib的quiver在画图前要转置矩阵?
Why does matplotlib's quiver transpose matrices before drawing?
我正在尝试使用 quiver,但我很难理解 quiver 如何解释其文档中的输入数组 U、V https://matplotlib.org/3.5.0/api/_as_gen/matplotlib.pyplot.quiver.html
使用以下代码,我希望右下角的箭头(元素 [2,0])指向左侧。但是如图所示是左上角
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.3,.9,3)
y = x
nb_points = x.size
X,Y = np.meshgrid(x,y)
U = np.ones((nb_points, nb_points))
V = np.ones((nb_points, nb_points))
U[2,0] = -3
M = (np.hypot(U, V))
fig,ax = plt.subplots(1,1, figsize=(4,4))
ax.quiver(X, Y, U, V, M, units='width', pivot='middle')
ax.set_xlim(.2,1)
ax.set_ylim(.2,1)
谁能解释一下这是怎么回事?
我完全误解了U,V的索引的意思
U[2,0]应该解释为X[2,0],Y[2,0] = (.3,.9)的方向,也就是top-left点
我正在尝试使用 quiver,但我很难理解 quiver 如何解释其文档中的输入数组 U、V https://matplotlib.org/3.5.0/api/_as_gen/matplotlib.pyplot.quiver.html
使用以下代码,我希望右下角的箭头(元素 [2,0])指向左侧。但是如图所示是左上角
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.3,.9,3)
y = x
nb_points = x.size
X,Y = np.meshgrid(x,y)
U = np.ones((nb_points, nb_points))
V = np.ones((nb_points, nb_points))
U[2,0] = -3
M = (np.hypot(U, V))
fig,ax = plt.subplots(1,1, figsize=(4,4))
ax.quiver(X, Y, U, V, M, units='width', pivot='middle')
ax.set_xlim(.2,1)
ax.set_ylim(.2,1)
谁能解释一下这是怎么回事?
我完全误解了U,V的索引的意思
U[2,0]应该解释为X[2,0],Y[2,0] = (.3,.9)的方向,也就是top-left点