diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7f6c01089d0d..fc19f6108d13 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -411,10 +411,12 @@ def cycle_or_default(seq, default=None): gc0.set_linewidth(lw) if Nlinestyles: gc0.set_dashes(*ls) - if len(ec) == 4 and ec[3] == 0.0: + ec_rgba = colors.to_rgba(ec) + # Fully transparent edges are treated as "no stroke". + if ec_rgba[3] == 0.0: gc0.set_linewidth(0) else: - gc0.set_foreground(ec) + gc0.set_foreground(ec_rgba, isRGBA=True) if Nhatchcolors: gc0.set_hatch_color(hc) if fc is not None and len(fc) == 4 and fc[3] == 0: diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 23f516aa6337..bbc8e57d7a05 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -411,7 +411,7 @@ def draw(self, renderer): gc.set_capstyle(self._capstyle) if do_single_path_optimization: - gc.set_foreground(tuple(edgecolors[0])) + gc.set_foreground(tuple(edgecolors[0]), isRGBA=True) gc.set_linewidth(self._linewidths[0]) gc.set_dashes(*self._linestyles[0]) gc.set_antialiased(self._antialiaseds[0]) diff --git a/lib/matplotlib/patheffects.py b/lib/matplotlib/patheffects.py index f700feac6292..ae808eb62fbe 100644 --- a/lib/matplotlib/patheffects.py +++ b/lib/matplotlib/patheffects.py @@ -269,7 +269,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace): else: shadow_rgbFace = self._shadow_rgbFace - gc0.set_foreground("none") + gc0.set_foreground(mcolors.to_rgba("none"), isRGBA=True) gc0.set_alpha(self._alpha) gc0.set_linewidth(0) @@ -331,7 +331,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace): else: shadow_rgbFace = self._shadow_color - gc0.set_foreground(shadow_rgbFace) + gc0.set_foreground(mcolors.to_rgba(shadow_rgbFace), isRGBA=True) gc0.set_alpha(self._alpha) gc0 = self._update_gc(gc0, self._gc) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index d794cab1339b..cbeba1f84307 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -11,7 +11,7 @@ import numpy as np import matplotlib as mpl -from . import _api, artist, cbook, _docstring +from . import _api, artist, cbook, _docstring, colors as mcolors from .artist import Artist from .font_manager import FontProperties from .patches import FancyArrowPatch, FancyBboxPatch, Rectangle @@ -864,7 +864,7 @@ def draw(self, renderer): self._bbox_patch.draw(renderer) gc = renderer.new_gc() - gc.set_foreground(self.get_color()) + gc.set_foreground(mcolors.to_rgba(self.get_color()), isRGBA=True) gc.set_alpha(self.get_alpha()) gc.set_url(self._url) gc.set_antialiased(self._antialiased) diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index e4628f99e420..dd0ed6b583f7 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -178,7 +178,8 @@ def draw(self, renderer): return gc = renderer.new_gc() - gc.set_foreground(self.get_markeredgecolor()) + edgecolor = mcolors.to_rgba(self.get_markeredgecolor()) + gc.set_foreground(edgecolor, isRGBA=True) gc.set_linewidth(self.get_markeredgewidth()) gc.set_alpha(self._alpha)