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

Commit16ae71f

Browse files
authored
Merge pull request#17543 from timhoffm/unfilled-markers
Fix linewidths and colors for scatter() with unfilled markers
2 parents7a6c5d3 +d86cc2b commit16ae71f

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
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/markers.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ def _recache(self):
232232
self._snap_threshold=None
233233
self._joinstyle='round'
234234
self._capstyle='butt'
235-
self._filled=True
235+
# Initial guess: Assume the marker is filled unless the fillstyle is
236+
# set to 'none'. The marker function will override this for unfilled
237+
# markers.
238+
self._filled=self._fillstyle!='none'
236239
self._marker_function()
237240

238241
def__bool__(self):

‎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):

‎lib/matplotlib/tests/test_marker.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
importpytest
88

99

10+
deftest_marker_fillstyle():
11+
marker_style=markers.MarkerStyle(marker='o',fillstyle='none')
12+
assertmarker_style.get_fillstyle()=='none'
13+
assertnotmarker_style.is_filled()
14+
15+
1016
deftest_markers_valid():
1117
marker_style=markers.MarkerStyle()
1218
mrk_array=np.array([[-0.5,0],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp