Description
Bug summary
I observed a result that is not documented and want help to determine whether this is the desired behavior:
Below is a script from test_quiver.py
. In the last line we want to plot (in the lower ax) a quiverkey
in the with 45 degree. My understand is that angle
specified in quiverkey
is for the rectangular canvas we are drawing on, therefore, independent of what we are plotting, what the coordinate axes look like. So it should be 45 degree from horizontal axis.
The current implementation attempts to map the angle
to other things if scale_units='xy'
or angle='xy'
is set in quiver()
. This mapping is problematic and is the root cause of issues like #26316 and #26748. I found something else in Quiver
that also needs to be fixed, so it's not a one-liner fix that I talked about today... I will post more details about the investigation and possible fix in a PR later.
Old business for recap: On the call today, we discussed about that angle
in QuiverKey() should be calculated from x-axis or horizontal-axis, I guess we are not opposed to the idea of "horizontal-axis"?
Code for reproduction
X = np.arange(8)
Y = np.zeros(8)
angles = X * (np.pi / 4)
uv = np.exp(1j * angles)
U = uv.real
V = uv.imag
fig, axs = plt.subplots(2)
for ax, angle_str in zip(axs, ('uv', 'xy')):
ax.set_xlim(-1, 8)
ax.set_ylim(-0.2, 0.2)
q = ax.quiver(X, Y, U, V, pivot='middle',
units='xy', width=0.05,
scale=2, scale_units='xy',
angles=angle_str)
print(X, Y, U, V, sep="\n")
ax.scatter(X, Y)
ax.plot([1, 1.7], [0, 0.7])
for x, angle in zip((0.2, 0.5, 0.8), (0, 45, 90)):
ax.quiverkey(q, X=x, Y=0.8, U=1, angle=angle, label='', color='b')
Actual outcome
The blue arrow in the bottom is not 45 degree
Expected outcome
The blue arrow in the bottom is 45 degree
Additional information
No response
Operating system
No response
Matplotlib Version
3.90dev
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None