Skip to content

improve legend docstring #9999

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

Merged
merged 1 commit into from
Dec 18, 2017
Merged

improve legend docstring #9999

merged 1 commit into from
Dec 18, 2017

Conversation

timhoffm
Copy link
Member

PR Summary

This improves the legend docstrings:

  • describe handles and labels
  • add call signatures to Axes.legend()
  • Structure and reorder Axes.legend() so that the most common use case is at the top.

also fixes #8668

@timhoffm
Copy link
Member Author

Just saw the failing test, which compares if the parameter sections are identical for axes.legend() and Legend().

I assume the intent is to keep the long parameter lists at sync. However since the signatures are actually different, this does not work easily. Either one has to break with the documenting rules and exclude parent, handles and labels from the parameter sections (probably why the docstring was in the peculiar state before I changed it), or one has to refine the test.

How should I proceed?

@jklymak
Copy link
Member

jklymak commented Dec 14, 2017

Without looking too closely, can you keep "Parameters" as the arguments that change, and "Other Paramters" as the parameters that are shared and move the test to look at the "Other Parameters" section?

The problem before was that the very very very long list of kwargs was not consistent between the legend docstrings. I fixed that, and then introduced the test (#9324). If it had been up to me, we'd have used a doc interp, but the consensus seemed to be that we don't like doc interps. I'm not particularly happy w/ the existing solution, so other creative ideas more than welcome. I'm not going to be terribly upset if we get rid of the test for consistency, but there should be a way to keep the kwarg documentation consistent between the three legends. See also #9414.

@timhoffm
Copy link
Member Author

The workaround with "Other Parameters" should be ok in this case. Will look into it.

As of syncing docstrings, you just have the two options:

  • Sync manually and monitor deviations (--> current tests).
  • Any automatic mechanism at build or import-time.

I currently do not oversee the subtleties of the latter, and therefore, cannot comment here.

@timhoffm
Copy link
Member Author

Docstring / test adapted.

@jklymak
Copy link
Member

jklymak commented Dec 17, 2017

Test passed; you've got .legend in there somewhere, and its ambiguous between Figure.legend and axes.legend.

ax.legend()

Specific lines can be excluded from the automatic legend element
selection by defining a label starting with an underscore.
This is default for all artists, so calling :meth:`legend` without
This is default for all artists, so calling :meth:`.legend` without
Copy link
Member

Choose a reason for hiding this comment

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

This needs to me .Axes.legend I think

@jklymak jklymak merged commit 7231bd3 into matplotlib:master Dec 18, 2017
@QuLogic QuLogic added this to the v2.2 milestone Dec 18, 2017
@timhoffm timhoffm deleted the doc-legend branch January 3, 2018 16:47
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handles keyword argument not documented in the help of legend
4 participants