Skip to content

MNT: Remove redundant method, fix signature and add doc-string to draw_tex #24182

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
Oct 20, 2022
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
18 changes: 18 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,24 @@ def option_scale_image(self):

def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
"""
Draw a TeX instance.

Parameters
----------
gc : `.GraphicsContextBase`
The graphics context.
x : float
The x location of the text in display coords.
y : float
The y location of the text baseline in display coords.
s : str
The TeX text string.
prop : `matplotlib.font_manager.FontProperties`
The font properties.
angle : float
The rotation angle in degrees anti-clockwise.
mtext : `matplotlib.text.Text`
The original text object to be rendered.
"""
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ def draw_image(self, gc, x, y, im, transform=None):
interp, w, h, fname_img))
_writeln(self.fh, r"\end{pgfscope}")

def draw_tex(self, gc, x, y, s, prop, angle, ismath="TeX", mtext=None):
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this without deprecation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear. It is not used and was deprecated from all other draw_tex methods in #17484. However, it seems to have been forgotten for the pgf backend.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecations were removed in #19900 and while it was touched, it does not seem like anyone noticed that the signature was different.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's try.

# docstring inherited
self.draw_text(gc, x, y, s, prop, angle, ismath, mtext)
self.draw_text(gc, x, y, s, prop, angle, ismath="TeX", mtext=mtext)

def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
# docstring inherited
Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,10 +1292,6 @@ def _get_all_quoted_names(prop):

writer.end('g')

def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
# docstring inherited
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")

def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
# docstring inherited

Expand Down