Fix scatter edgecolor for unfilled points by has2k1 · Pull Request #10008 · matplotlib/matplotlib · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 deletions doc/api/next_api_changes/behavior/10008-HK.rst
14 changes: 9 additions & 5 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff 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 Down Expand 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 deletions lib/matplotlib/tests/test_axes.py