Skip to content

Deprecate ismath parameter to draw_tex and ismath="TeX!". #17484

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
May 26, 2020
Merged
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
13 changes: 13 additions & 0 deletions doc/api/api_changes_3.3/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,16 @@ Statusbar classes and attributes
The ``statusbar`` attribute of `.FigureManagerBase`, `.StatusbarBase` and all
its subclasses, and ``StatusBarWx``, are deprecated, as messages are now
displayed in the toolbar instead.

``ismath`` parameter of ``draw_tex``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``ismath`` parameter of the ``draw_tex`` method of all renderer classes is
deprecated (as a call to ``draw_tex`` -- not to be confused with ``draw_text``!
-- means that the entire string should be passed to the ``usetex`` machinery
anyways). Likewise, the text machinery will no longer pass the ``ismath``
parameter when calling ``draw_tex`` (this should only matter for backend
implementers).

Passing ``ismath="TeX!"`` to `.RendererAgg.get_text_width_height_descent` is
deprecated. Pass ``ismath="TeX"`` instead, consistently with other low-level
APIs which support the values True, False, and "TeX" for ``ismath``.
1 change: 1 addition & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def option_scale_image(self):
"""
return False

@cbook._delete_parameter("3.3", "ismath")
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
"""
"""
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ def get_text_width_height_descent(self, s, prop, ismath):
# docstring inherited

if ismath in ["TeX", "TeX!"]:
if ismath == "TeX!":
cbook._warn_deprecated(
"3.3", message="Support for ismath='TeX!' is deprecated "
"since %(since)s and will be removed %(removal)s; use "
"ismath='TeX' instead.")
# todo: handle props
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
Expand All @@ -238,6 +243,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
d /= 64.0
return w, h, d

@cbook._delete_parameter("3.2", "ismath")
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
# docstring inherited
# todo, handle props, angle, origins
Expand All @@ -248,7 +254,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
Z = texmanager.get_grey(s, size, self.dpi)
Z = np.array(Z * 255.0, np.uint8)

w, h, d = self.get_text_width_height_descent(s, prop, ismath)
w, h, d = self.get_text_width_height_descent(s, prop, ismath="TeX")
xd = d * sin(radians(angle))
yd = d * cos(radians(angle))
x = round(x + xd)
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
# Pop off the global transformation
self.file.output(Op.grestore)

@cbook._delete_parameter("3.3", "ismath")
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
# docstring inherited
texmanager = self.get_texmanager()
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,

self._path_collection_id += 1

@cbook._delete_parameter("3.3", "ismath")
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
# docstring inherited
if not hasattr(self, "psfrag"):
Expand All @@ -475,10 +476,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
"rcParams['text.usetex'] and does not support having "
"usetex=True only for some elements; this element will thus "
"be rendered as if usetex=False.")
self.draw_text(gc, x, y, s, prop, angle, ismath, mtext)
self.draw_text(gc, x, y, s, prop, angle, False, mtext)
return

w, h, bl = self.get_text_width_height_descent(s, prop, ismath)
w, h, bl = self.get_text_width_height_descent(s, prop, ismath="TeX")
fontsize = prop.get_size_in_points()
thetext = 'psmarker%d' % self.textcnt
color = '%1.3f,%1.3f,%1.3f' % gc.get_rgb()[:3]
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):

writer.end('g')

@cbook._delete_parameter("3.3", "ismath")
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
# docstring inherited
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def draw(self, renderer):
if textobj.get_usetex():
textrenderer.draw_tex(gc, x, y, clean_line,
textobj._fontproperties, angle,
ismath=ismath, mtext=mtext)
mtext=mtext)
else:
textrenderer.draw_text(gc, x, y, clean_line,
textobj._fontproperties, angle,
Expand Down