Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend does not work for quiver #2601

Closed
astrofrog opened this issue Nov 18, 2013 · 5 comments
Closed

Legend does not work for quiver #2601

astrofrog opened this issue Nov 18, 2013 · 5 comments

Comments

@astrofrog
Copy link
Contributor

It seems that labels do not work for quiver plots:

In [1]: x = np.random.random(100)

In [2]: y = np.random.random(100)

In [3]: u = np.random.random(100) / 30.

In [4]: v = np.random.random(100) / 30.

In [5]: plt.quiver(x, y, u, v, label='test')
Out[5]: <matplotlib.quiver.Quiver at 0x1076d1890>

In [6]: plt.legend()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.py:4747: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labeled objects found. "

Is support of this planned? If not, maybe it would make sense not to allow the label argument for quiver?

@tacaswell
Copy link
Member

There is a QuiverKey class which looks like it is for this purpose. I suspect this is an issue with the auto-magic that walks the artists and generates the pairs in ax.legend().

@efiring
Copy link
Member

efiring commented Nov 18, 2013

Right. I don't see how a legend makes much sense for quiver. What characteristics would you give the arrow?

@astrofrog
Copy link
Contributor Author

@efiring - what about just the same as for a line plot for the line part, but with an arrowhead that matches the plot?

@tacaswell
Copy link
Member

tacaswell commented Jan 24, 2014

@astrofrog See http://matplotlib.org/examples/pylab_examples/quiver_demo.html

I strongly suspect that you could pass a QuiverKey artist into the legend.

2020 Tom does not agree with 2014 Tom, see comment at #16664.

@tacaswell
Copy link
Member

@astrofrog Does quiverkey do what you need? I am going to close this, please re-open if quiverkey is not what you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants