8000 Text.{get,set}_usetex: manually enable/disable TeX by duncanmmacleod · Pull Request #3925 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Text.{get,set}_usetex: manually enable/disable TeX #3925

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

Merged
merged 1 commit into from
Dec 24, 2014
Merged
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
29 changes: 28 additions & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def get_rotation(rotation):
style or fontstyle [ 'normal' | 'italic' | 'oblique']
text string
transform a matplotlib.transform transformation instance
usetex [True | False | None]
variant ['normal' | 'small-caps']
verticalalignment or va ['center' | 'top' | 'bottom' | 'baseline']
visible [True | False]
Expand Down Expand Up @@ -173,6 +174,7 @@ def __init__(self,
rotation=None,
linespacing=None,
rotation_mode=None,
usetex=None, # defaults to rcParams['text.usetex']
**kwargs
):
"""
Expand All @@ -195,6 +197,7 @@ def __init__(self,

self.set_text(text)
self.set_color(color)
self.set_usetex(usetex)
self._verticalalignment = verticalalignment
self._horizontalalignment = horizontalalignment
self._multialignment = multialignment
Expand Down Expand Up @@ -582,7 +585,7 @@ def draw(self, renderer):
renderer = PathEffectRenderer(self.get_path_effects(),
renderer)

if rcParams['text.usetex']:
if self.get_usetex():
renderer.draw_tex(gc, x, y, clean_line,
self._fontproperties, angle, mtext=mtext)
else:
Expand Down Expand Up @@ -1010,6 +1013,30 @@ def set_font_properties(self, fp):
'alias for set_fontproperties'
self.set_fontproperties(fp)

def set_usetex(self, usetex):
"""
Set this `Text` object to render using TeX (or not).

If `None` is given, the option will be reset to use the value of
`rcParams['text.usetex']`
"""
if usetex is None:
self._usetex = None
else:
self._usetex = bool(usetex)

def get_usetex(self):
"""
Return whether this `Text` object will render using TeX.

If the user has not manually set this value, it will default to
the value of `rcParams['text.usetex']`
"""
if self._usetex is None:
return rcParams['text.usetex']
else:
return self._usetex

docstring.interpd.update(Text=artist.kwdoc(Text))
docstring.dedent_interpd(Text.__init__)

Expand Down
0