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

Fix scatter edgecolor for unfilled points#10008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletionsdoc/api/next_api_changes/behavior/10008-HK.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
Scatter plot unfilled marker edgecolor
--------------------------------------

For :meth:`~matplotlib.axes.Axes.scatter`, when both the `facecolor`
and `edgecolor` are specified for unfilled marker types, the `edgecolor`
is used. Previously, the points took on the `facecolor`.
14 changes: 9 additions & 5 deletionslib/matplotlib/axes/_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4291,9 +4291,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
- 'none': No patch boundary will be drawn.
- A color or sequence of colors.

For non-filled markers, *edgecolors* is ignored. Instead, the color
is determined like with 'face', i.e. from *c*, *colors*, or
*facecolors*.
For non-filled markers, *edgecolors* kwarg (if it is not None,
'face' or 'none') dictates the color of the marker.

plotnonfinite : bool, default: False
Whether to plot points with nonfinite *c* (i.e. ``inf``, ``-inf``
Expand DownExpand Up@@ -4378,6 +4377,11 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
path = marker_obj.get_path().transformed(
marker_obj.get_transform())
if not marker_obj.is_filled():
# In classic mode or non-classic mode
if edgecolors is None or edgecolors == 'face':
edgecolors = colors
colors = 'none'

if linewidths is None:
linewidths = rcParams['lines.linewidth']
elif np.iterable(linewidths):
Expand All@@ -4389,8 +4393,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,

collection = mcoll.PathCollection(
(path,), scales,
facecolors=colors if marker_obj.is_filled() else 'none',
edgecolors=edgecolors if marker_obj.is_filled() else colors,
facecolors=colors,
edgecolors=edgecolors,
linewidths=linewidths,
offsets=offsets,
transOffset=kwargs.pop('transform', self.transData),
Expand Down
15 changes: 15 additions & 0 deletionslib/matplotlib/tests/test_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2367,6 +2367,21 @@ def get_next_color():
c, None, kwargs={}, xsize=2, get_next_color_func=get_next_color)


@pytest.mark.parametrize(('facecolor', 'edgecolor', 'expected_color'), [
('red', 'cyan', 'cyan'),
(None, 'cyan', 'cyan'),
('red', None, 'red')
])
def test_scatter_edgecolor(facecolor, edgecolor, expected_color):
fig, ax = plt.subplots()
artist = ax.scatter(x=[1, 2, 3], y=[1, 2, 3], s=550,
linewidth=5, marker='2',
facecolor=facecolor,
edgecolor=edgecolor)
result_color = artist.get_edgecolor()[0]
assert mcolors.to_hex(result_color) == mcolors.to_hex(expected_color)


def test_as_mpl_axes_api():
# tests the _as_mpl_axes api
from matplotlib.projections.polar import PolarAxes
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp