我正在尝试将仿射变换应用于箭袋图。这是一个基于matplotlib箭头演示之一的示例。当前,绘图命令的结果转换一个方向,而箭头命令的结果转向另一个方向。为什么这样,我该如何解决?
import matplotlib as mpl
from pylab import *
from numpy import ma
X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) )
U = cos(X)
V = sin(Y)
#3
fig = figure()
ax = subplot(111)
base_trans = ax.transData
tr = mpl.transforms.Affine2D(matrix = array([[1,1,0],[0,1,0],[0,0,1]])) + base_trans
Q = quiver( X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
pivot='mid', color='r', units='inches', transform = tr )
qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'})
plot( X[::3, ::3], Y[::3, ::3], 'k.', transform = tr)
axis([-1, 7, -1, 7])
fig.savefig('demo.png')
show()