Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd86cc2b

Browse files
committed
Fix colors for scatter() with unfilled markers
Previously, markers with fillstyle='none' still were drawn with a facecolor.
1 parent2a3707d commitd86cc2b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

‎lib/matplotlib/axes/_axes.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4393,8 +4393,9 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43934393
- 'none': No patch boundary will be drawn.
43944394
- A color or sequence of colors.
43954395
4396-
For non-filled markers, the *edgecolors* kwarg is ignored and
4397-
forced to 'face' internally.
4396+
For non-filled markers, *edgecolors* is ignored. Instead, the color
4397+
is determined like with 'face', i.e. from *c*, *colors*, or
4398+
*facecolors*.
43984399
43994400
plotnonfinite : bool, default: False
44004401
Set to plot points with nonfinite *c*, in conjunction with
@@ -4476,7 +4477,6 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44764477
path=marker_obj.get_path().transformed(
44774478
marker_obj.get_transform())
44784479
ifnotmarker_obj.is_filled():
4479-
edgecolors='face'
44804480
iflinewidthsisNone:
44814481
linewidths=rcParams['lines.linewidth']
44824482
elifnp.iterable(linewidths):
@@ -4488,8 +4488,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44884488

44894489
collection=mcoll.PathCollection(
44904490
(path,),scales,
4491-
facecolors=colors,
4492-
edgecolors=edgecolors,
4491+
facecolors=colorsifmarker_obj.is_filled()else'none',
4492+
edgecolors=edgecolorsifmarker_obj.is_filled()elsecolors,
44934493
linewidths=linewidths,
44944494
offsets=offsets,
44954495
transOffset=kwargs.pop('transform',self.transData),

‎lib/matplotlib/tests/test_axes.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,16 @@ def test_scatter_color(self):
18371837
withpytest.raises(ValueError):
18381838
plt.scatter([1,2,3], [1,2,3],color=[1,2,3])
18391839

1840+
deftest_scatter_unfilled(self):
1841+
coll=plt.scatter([0,1,2], [1,3,2],c=['0.1','0.3','0.5'],
1842+
marker=mmarkers.MarkerStyle('o',fillstyle='none'),
1843+
linewidths=[1.1,1.2,1.3])
1844+
assertcoll.get_facecolors().shape== (0,4)# no facecolors
1845+
assert_array_equal(coll.get_edgecolors(), [[0.1,0.1,0.1,1],
1846+
[0.3,0.3,0.3,1],
1847+
[0.5,0.5,0.5,1]])
1848+
assert_array_equal(coll.get_linewidths(), [1.1,1.2,1.3])
1849+
18401850
deftest_scatter_size_arg_size(self):
18411851
x=np.arange(4)
18421852
withpytest.raises(ValueError):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp