-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Description
Feature Request
Feature summary
I'd like to be able to add the QuiverKey object to the legend as a handle. So the length of the arrow in the legend is meaningful to the quivers on the plot, but so it can be displayed in a tidy way with more mixed plot types. This was mentioned on another issue, but I don't think it's actually been implemented.
Code for reproduction
from matplotlib.patches import Patch
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
X = np.arange(-10, 10, 1)
Y = np.arange(-10, 10, 1)
U, V = np.meshgrid(X, Y)
q = ax.quiver(X, Y, U, V)
qk = ax.quiverkey(q, 0.9,0.8, U=10, label='QK length = 10', labelpos='E')
legend_elements = [
Patch(facecolor="red", edgecolor="black", label="First Element"),
qk
]
ax.legend(handles=legend_elements)
plt.show()
Actual outcome
/opt/conda/envs/py37/lib/python3.7/site-packages/ipykernel_launcher.py:20: UserWarning: Legend does not support <matplotlib.quiver.QuiverKey object at 0x7fcf101d7b00> instances.
A proxy artist may be used instead.
See: http://matplotlib.org/users/legend_guide.html#creating-artists-specifically-for-adding-to-the-legend-aka-proxy-artists
Expected outcome
Have the quiverkey as another element in the legend box with my other proxies. If I create a proxy as the error suggests, it will lose it's meaningful length and therefore it's value as a "key".
Matplotlib version
- Operating system: Linux Mint
- Matplotlib version: 3.1.2
- Matplotlib backend: module://ipykernel.pylab.backend_inline
- Python version: 3.7.3