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

Commit88cd5fd

Browse files
committed
Fix scatter edgecolor for unfilled points
For unfilled markers, the edgecolor -- if specified -- has precedenceover the facecolor.closeshas2k1/plotnine#100
1 parent49d5ced commit88cd5fd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

‎doc/api/api_changes/2017-12-14-HK.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Scatter plot unfilled marker edgecolor
2+
--------------------------------------
3+
4+
For:meth:`~matplotlib.axes.Axes.scatter`, when both the `facecolor`
5+
and `edgecolor` are specified for unfilled marker types, the `edgecolor`
6+
is used. Previously, the points took on the `facecolor`.

‎lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,8 +3873,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
38733873
If it is 'none', the patch boundary will not
38743874
be drawn.
38753875
3876-
For non-filled markers, the `edgecolors` kwarg
3877-
is ignored and forced to 'face' internally.
3876+
For non-filled markers, the `edgecolors` kwarg (if it is not
3877+
None, 'face' or 'none') dictates the color of the marker.
38783878
38793879
Returns
38803880
-------
@@ -4024,7 +4024,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
40244024
path=marker_obj.get_path().transformed(
40254025
marker_obj.get_transform())
40264026
ifnotmarker_obj.is_filled():
4027-
edgecolors='face'
4027+
ifedgecolorsisNone:
4028+
edgecolors='face'
40284029
linewidths=rcParams['lines.linewidth']
40294030

40304031
offsets=np.column_stack([x,y])

‎lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,21 @@ def test_scatter_color():
17331733
plt.scatter([1,2,3], [1,2,3],color=[1,2,3])
17341734

17351735

1736+
@pytest.mark.parametrize(('facecolor','edgecolor','expected_color'), [
1737+
('red','cyan','cyan'),
1738+
(None,'cyan','cyan'),
1739+
('red',None,'red')
1740+
])
1741+
deftest_scatter_edgecolor(facecolor,edgecolor,expected_color):
1742+
fig,ax=plt.subplots()
1743+
artist=ax.scatter(x=[1,2,3],y=[1,2,3],s=550,
1744+
linewidth=5,marker='2',
1745+
facecolor=facecolor,
1746+
edgecolor=edgecolor)
1747+
result_color=artist.get_edgecolor()[0]
1748+
assertmcolors.to_hex(result_color)==mcolors.to_hex(expected_color)
1749+
1750+
17361751
deftest_as_mpl_axes_api():
17371752
# tests the _as_mpl_axes api
17381753
frommatplotlib.projections.polarimportPolarAxes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp