Skip to content

ENH: plotting methods can unpack labeled data [MOVED TO #4829] #4787

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

Closed
wants to merge 8 commits into from
Prev Previous commit
FIX: fix yet more typos
  • Loading branch information
tacaswell committed Jul 29, 2015
commit 4059b448666c63b6b532f93ccde3043f60fd8e3c
5 changes: 4 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,9 @@ def inner(ax, *args, **kwargs):
new_kwargs = dict(
(k, _replacer(data, v) if k in wl_kwargs else v)
for k, v in six.iteritems(kwargs))
else:
new_args, new_kwargs = args, kwargs

if (label_pos is not None and ('label' not in kwargs or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't check against the case that a user called the function with args alone (aka: the new label is in args). Not sure how frequent that is...

def plotter(ax, x, y, label=None):
    pass

plotter(None, 1,2,"label")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, but I am not super worried about that in this case because in order for this code path to be hit they have to be using the data kwarg so we won't break un-touched user code.

Some of the methods take label as an explicit input, but many take it through a blind **kwargs. I suspect that we will have to inspect func on the way in.

kwargs['label'] is None)):
if len(args) > label_arg:
Expand All @@ -1572,7 +1575,7 @@ def inner(ax, *args, **kwargs):
pass
elif label_kwarg in kwargs:
try:
kwargs['label'] = kwargs[label_kwarg].name
new_kwargs['label'] = kwargs[label_kwarg].name
except AttributeError:
pass

Expand Down