Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 329291f

Browse files
authored
Merge pull request #21471 from meeseeksmachine/auto-backport-of-pr-21470-on-v3.5.x
Backport PR #21470 on branch v3.5.x (Hide fully transparent latex text in PS output)
2 parents 6b48bc2 + f47893f commit 329291f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
593593
@_log_if_debug_on
594594
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
595595
# docstring inherited
596+
if self._is_transparent(gc.get_rgb()):
597+
return # Special handling for fully transparent.
598+
596599
if not hasattr(self, "psfrag"):
597600
self._logwarn_once(
598601
"The PS backend determines usetex status solely based on "

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ def test_transparency():
118118
ax.text(.5, .5, "foo", color="r", alpha=0)
119119

120120

121+
@needs_usetex
122+
@image_comparison(["empty.eps"])
123+
def test_transparency_tex():
124+
mpl.rcParams['text.usetex'] = True
125+
fig, ax = plt.subplots()
126+
ax.set_axis_off()
127+
ax.plot([0, 1], color="r", alpha=0)
128+
ax.text(.5, .5, "foo", color="r", alpha=0)
129+
130+
121131
def test_bbox():
122132
fig, ax = plt.subplots()
123133
with io.BytesIO() as buf:

0 commit comments

Comments
 (0)