Skip to content

Commit bdfb68f

Browse files
committed
Make example in legend_elements doc more generalisable
1 parent d57fa97 commit bdfb68f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/collections.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,12 @@ def legend_elements(self, prop="colors", num="auto",
10381038
Create legend handles and labels for a PathCollection.
10391039
10401040
Each legend handle is a `.Line2D` representing the Path that was drawn,
1041-
and each label is a string what each Path represents.
1041+
and each label is a string that represents the Path.
10421042
10431043
This is useful for obtaining a legend for a `~.Axes.scatter` plot;
10441044
e.g.::
10451045
1046-
scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3])
1046+
scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3], num=None)
10471047
plt.legend(*scatter.legend_elements())
10481048
10491049
creates three legend elements, one for each color with the numerical
@@ -1119,6 +1119,7 @@ def legend_elements(self, prop="colors", num="auto",
11191119
raise ValueError("Valid values for `prop` are 'colors' or "
11201120
f"'sizes'. You supplied '{prop}' instead.")
11211121

1122+
11221123
fu = func(u)
11231124
fmt.axis.set_view_interval(fu.min(), fu.max())
11241125
fmt.axis.set_data_interval(fu.min(), fu.max())

0 commit comments

Comments
 (0)