-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
2.1 figure.legend broken #9320
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
Comments
There is many more issues. mpl 2.1.0 is not a production version. |
Can you please provide a runnable example? |
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 2)
hs = []
for axx in ax:
h = axx.plot(np.arange(10))
hs += [h]
fig.legend(handles=hs, labels=['Boo', 'Hoo'])
plt.show() Doesn't make a legend and returns:
This is using master. |
@dstansby It looks like you maybe made this change? Are we dropping support for @2sn : positional arguments work, and indeed the documented version of fig, ax = plt.subplots(1, 2)
hs = []
lab = ['Boo', 'Hoo']
for nn, axx in enumerate(ax):
h, = axx.plot(np.arange(10))
hs += [h]
fig.legend(hs, lab)
plt.show() |
Do you have a PR/commit reference for where I made the change? Can't remember anything like this off the top of my head. |
According to the In the mean time, just dropping |
Because they were named args before, the expectation is that they will work as kwargs as well. This is a regression that should be fixed (and it is a easy fix, just check if they are in kwargs before falling back to searching). |
I'd fix this, but I don't understand why |
Also makes scikit-learn doc builds fail at https://github.com/scikit-learn/scikit-learn/blob/master/examples/neural_networks/plot_mlp_training_curves.py#L88 |
See or #9324 for possible fix. However I wouldn’t expect every invocation combination to be respected. |
Yes, I had looked at the source file rather than the doc and used the names positional arguments from there. I think it is better being able to give them as named arguments that can be passed as keywords so you don't have to remember the order. Explicit is better. Thanks for fixing! |
PS - I have edited my code to now use positional arguments, but the old behaviour was nicer. |
Bug report
figure.legend no longer accepts "handles" and and "labels" as keywords
Code for reproduction
If applicable, paste the console output here
~/Python/lib/python3.6/site-packages/matplotlib/figure.py in legend(self, *args, **kwargs)
1523 '(artist handles, figure labels, legend location)')
1524
-> 1525 l = Legend(self, handles, labels, **kwargs)
1526 self.legends.append(l)
1527 l._remove_method = lambda h: self.legends.remove(h)
TypeError: init() got multiple values for argument 'handles'
The text was updated successfully, but these errors were encountered: