diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 703a77ee593a..567feb5cc6cc 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -393,7 +393,7 @@ def draw(self, renderer): edgecolors = self.get_edgecolor() do_single_path_optimization = False if (len(paths) == 1 and len(trans) <= 1 and - len(facecolors) == 1 and len(edgecolors) == 1 and + len(facecolors) <= 1 and len(edgecolors) <= 1 and len(self._linewidths) == 1 and all(ls[1] is None for ls in self._linestyles) and len(self._antialiaseds) == 1 and len(self._urls) == 1 and @@ -414,14 +414,16 @@ def draw(self, renderer): gc.set_capstyle(self._capstyle) if do_single_path_optimization: - gc.set_foreground(tuple(edgecolors[0]), isRGBA=True) + edgecolor = edgecolors[0] if len(edgecolors) == 1 else (0, 0, 0, 0) + facecolor = facecolors[0] if len(facecolors) == 1 else (0, 0, 0, 0) + gc.set_foreground(tuple(edgecolor), isRGBA=True) gc.set_linewidth(self._linewidths[0]) gc.set_dashes(*self._linestyles[0]) gc.set_antialiased(self._antialiaseds[0]) gc.set_url(self._urls[0]) renderer.draw_markers( gc, paths[0], combined_transform.frozen(), - mpath.Path(offsets), offset_trf, tuple(facecolors[0])) + mpath.Path(offsets), offset_trf, tuple(facecolor)) else: # The current new API of draw_path_collection() is provisional # and will be changed in a future PR. diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index fb3cae3474f1..752447c790f2 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3217,6 +3217,16 @@ def test_scatter_singular_plural_arguments(self): facecolors=["#ffffff", "#000000", "#f0f0f0"], facecolor="#ffffff") + @check_figures_equal() + def test_scatter_color_none(self, fig_test, fig_ref): + ax_test = fig_test.subplots() + ax_test.scatter([1], [1], facecolor='red', edgecolor='none') + ax_test.scatter([2], [2], facecolor='none', edgecolor='blue') + + ax_ref = fig_ref.subplots() + ax_ref.scatter([1], [1], facecolor='red', edgecolor=(0, 0, 0, 0)) + ax_ref.scatter([2], [2], facecolor=(0, 0, 0, 0), edgecolor='blue') + def _params(c=None, xsize=2, *, edgecolors=None, **kwargs): return (c, edgecolors, kwargs, xsize)