Skip to content

Make example in legend_elements doc more generalisable #27846

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
Mar 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,12 +1038,12 @@ def legend_elements(self, prop="colors", num="auto",
Create legend handles and labels for a PathCollection.

Each legend handle is a `.Line2D` representing the Path that was drawn,
and each label is a string what each Path represents.
and each label is a string that represents the Path.

This is useful for obtaining a legend for a `~.Axes.scatter` plot;
e.g.::

scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3])
scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3], num=None)
plt.legend(*scatter.legend_elements())

creates three legend elements, one for each color with the numerical
Expand Down