Skip to content

Commit

Permalink
Fixed miss matching string on test_scatter_singular_plural_arguments,…
Browse files Browse the repository at this point in the history
… add reset of linewidths and edgecolors after normalize_kwargs
  • Loading branch information
root authored and root committed May 24, 2023
1 parent 5093491 commit db60c1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4552,13 +4552,18 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
size matches the size of *x* and *y*.
"""

if edgecolors:
# add edgecolors and linewidths to kwargs so they
# can be processed by normailze_kwargs
if edgecolors is not None:
kwargs.update({'edgecolors': edgecolors})
if linewidths:
if linewidths is not None:
kwargs.update({'linewidths': linewidths})

kwargs = cbook.normalize_kwargs(kwargs, mcoll.Collection)
# re direct linewidth and edgecolor so it can be
# further processed by the rest of the function
linewidths = kwargs.pop('linewidth', None)
edgecolors = kwargs.pop('edgecolor', None)
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
x, y = self._process_unit_info([("x", x), ("y", y)], kwargs)
# np.ma.ravel yields an ndarray, not a masked array,
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2708,19 +2708,19 @@ def test_scatter_singular_plural_arguments(self):

with pytest.raises(TypeError,
match="Got both 'linewidth' and 'linewidths',\
which are aliases of one another"):
which are aliases of one another"):
plt.scatter([1, 2, 3], [1, 2, 3], linewidths=[0.5, 0.4, 0.3], linewidth=0.2)

with pytest.raises(TypeError,
match="Got both 'edgecolor' and 'edgecolors',\
which are aliases of one another"):
which are aliases of one another"):
plt.scatter([1, 2, 3], [1, 2, 3],
edgecolors=["#ffffff", "#000000", "#f0f0f0"],
edgecolor="#ffffff")

with pytest.raises(TypeError,
match="Got both 'facecolor' and 'facecolors',\
which are aliases of one another"):
which are aliases of one another"):
plt.scatter([1, 2, 3], [1, 2, 3],
facecolors=["#ffffff", "#000000", "#f0f0f0"],
facecolor="#ffffff")
Expand Down

0 comments on commit db60c1d

Please sign in to comment.