Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError when saving figure with partial Latex elements as a postscript (issue 7741) #8329

Closed
wants to merge 8 commits into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Expand Up @@ -635,7 +635,7 @@ def text(self, x, y, s, fontdict=None,
x=x, y=y, text=s)
else:
t = mtext.Text(
x=x, y=y, text=s)
x=x, y=y, text=s, usetex=kwargs.get('usetex'))

t.update(default)
if fontdict is not None:
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Expand Up @@ -188,3 +188,12 @@ def test_determinism_all():
def test_determinism_all_tex():
"""Test for reproducible PS/tex output"""
_determinism_check(format="ps", usetex=True)


@needs_tex
def test_usetex_param():
"""Test for Issue #7741 (this shouldn't crash)"""
fig = plt.figure()
plt.text(0.5, 0.5, 'some text, $math mode$',
ha='center', va='center', usetex=True)
fig.savefig('test.ps')
1 change: 1 addition & 0 deletions lib/matplotlib/text.py
Expand Up @@ -1261,6 +1261,7 @@ def set_usetex(self, usetex):
self._usetex = rcParams['text.usetex']
else:
self._usetex = bool(usetex)
rcParams['text.usetex'] = self._usetex
self.stale = True

def get_usetex(self):
Expand Down