diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index 93d0705ae363..fc1e73d4b18e 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -593,6 +593,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms, @_log_if_debug_on def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): # docstring inherited + if self._is_transparent(gc.get_rgb()): + return # Special handling for fully transparent. + if not hasattr(self, "psfrag"): self._logwarn_once( "The PS backend determines usetex status solely based on " diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index 74776fd048a6..50b1b0bc0cbe 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -118,6 +118,16 @@ def test_transparency(): ax.text(.5, .5, "foo", color="r", alpha=0) +@needs_usetex +@image_comparison(["empty.eps"]) +def test_transparency_tex(): + mpl.rcParams['text.usetex'] = True + fig, ax = plt.subplots() + ax.set_axis_off() + ax.plot([0, 1], color="r", alpha=0) + ax.text(.5, .5, "foo", color="r", alpha=0) + + def test_bbox(): fig, ax = plt.subplots() with io.BytesIO() as buf: