Skip to content

Allow use of usetex for only some artists in PS output. #10170

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

Closed
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ def __init__(self, width, height, pswriter, imagedpi=72):
self.width = width
self.height = height
self._pswriter = pswriter
if rcParams['text.usetex']:
self.textcnt = 0
self.psfrag = []

self.imagedpi = imagedpi

# Only used by usetex elements.
self.textcnt = 0
self.psfrag = []

# current renderer state (None=uninitialised)
self.color = None
self.linewidth = None
Expand Down Expand Up @@ -314,7 +316,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
with FontPropertry prop

"""
if rcParams['text.usetex']:
if ismath == "TeX":
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,12 @@ def test_determinism_all():
def test_determinism_all_tex():
"""Test for reproducible PS/tex output"""
_determinism_check(format="ps", usetex=True)


@needs_usetex
def test_partial_usetex():
"""Test that one can set usetex on just one artist (#7741)."""
fig = plt.figure()
plt.text(0.5, 0.5, 'some text, $math mode$',
ha='center', va='center', usetex=True)
fig.savefig('test.ps')
Binary file added test.ps
Binary file not shown.