Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f1e0274

Browse filesBrowse files
authored
Merge pull request #25794 from MichaelTheFear/raise_on_plural_scatter
Raise on plural scatter
2 parents ba952dd + fe47f20 commit f1e0274
Copy full SHA for f1e0274

File tree

Expand file treeCollapse file tree

2 files changed

+33
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+33
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,18 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
45954595
size matches the size of *x* and *y*.
45964596
45974597
"""
4598+
# add edgecolors and linewidths to kwargs so they
4599+
# can be processed by normailze_kwargs
4600+
if edgecolors is not None:
4601+
kwargs.update({'edgecolors': edgecolors})
4602+
if linewidths is not None:
4603+
kwargs.update({'linewidths': linewidths})
4604+
4605+
kwargs = cbook.normalize_kwargs(kwargs, mcoll.Collection)
4606+
# re direct linewidth and edgecolor so it can be
4607+
# further processed by the rest of the function
4608+
linewidths = kwargs.pop('linewidth', None)
4609+
edgecolors = kwargs.pop('edgecolor', None)
45984610
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
45994611
x, y = self._process_unit_info([("x", x), ("y", y)], kwargs)
46004612
# np.ma.ravel yields an ndarray, not a masked array,

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,27 @@ def test_scatter_linewidths(self):
27462746
assert_array_equal(pc.get_linewidths(),
27472747
[*range(1, 5), mpl.rcParams['lines.linewidth']])
27482748

2749+
def test_scatter_singular_plural_arguments(self):
2750+
2751+
with pytest.raises(TypeError,
2752+
match="Got both 'linewidth' and 'linewidths',\
2753+
which are aliases of one another"):
2754+
plt.scatter([1, 2, 3], [1, 2, 3], linewidths=[0.5, 0.4, 0.3], linewidth=0.2)
2755+
2756+
with pytest.raises(TypeError,
2757+
match="Got both 'edgecolor' and 'edgecolors',\
2758+
which are aliases of one another"):
2759+
plt.scatter([1, 2, 3], [1, 2, 3],
2760+
edgecolors=["#ffffff", "#000000", "#f0f0f0"],
2761+
edgecolor="#ffffff")
2762+
2763+
with pytest.raises(TypeError,
2764+
match="Got both 'facecolors' and 'facecolor',\
2765+
which are aliases of one another"):
2766+
plt.scatter([1, 2, 3], [1, 2, 3],
2767+
facecolors=["#ffffff", "#000000", "#f0f0f0"],
2768+
facecolor="#ffffff")
2769+
27492770

27502771
def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
27512772
return (c, edgecolors, kwargs if kwargs is not None else {}, xsize)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.