8000 Correctly set default linewidth for unfilled markers. · QuLogic/matplotlib@66289c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 66289c4

Browse files
committed
Correctly set default linewidth for unfilled markers.
Fixes matplotlib#17192.
1 parent 49593b7 commit 66289c4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4492,7 +4492,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44924492
marker_obj.get_transform())
44934493
if not marker_obj.is_filled():
44944494
edgecolors = 'face'
4495-
linewidths = rcParams['lines.linewidth']
4495+
if linewidths is None:
4496+
linewidths = rcParams['lines.linewidth']
4497+
elif np.iterable(linewidths):
4498+
linewidths = [
4499+
lw if lw is not None else rcParams['lines.linewidth']
4500+
for lw in linewidths]
44964501

44974502
offsets = np.ma.column_stack([x, y])
44984503

lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,20 @@ def test_scatter_single_color_c(self, fig_test, fig_ref):
19841984
ax_test.scatter(np.ones(3), range(3), c=rgb)
19851985
ax_test.scatter(np.ones(4)*2, range(4), c=rgba)
19861986

1987+
def test_scatter_linewidths(self):
1988+
x = np.arange(5)
1989+
1990+
fig, ax = plt.subplots()
1991+
for i in range(3):
1992+
pc = ax.scatter(x, np.full(5, i), c=f'C{i}', marker='x', s=100,
1993+
linewidths=i + 1)
1994+
assert pc.get_linewidths() == i + 1
1995+
1996+
pc = ax.scatter(x, np.full(5, 3), c='C3', marker='x', s=100,
1997+
linewidths=[*range(1, 5), None])
1998+
assert_array_equal(pc.get_linewidths(),
1999+
[*range(1, 5), mpl.rcParams['lines.linewidth']])
2000+
19872001

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

0 commit comments

Comments
 (0)
0