Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support\underline in Mathtext.#23616

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
tfpf wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromtfpf:underline
Draft
Show file tree
Hide file tree
Changes fromall 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
11 changes: 11 additions & 0 deletionsdoc/users/next_whats_new/mathtext_underline.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
Underlining text while using Mathtext
-------------------------------------

Mathtext now supports the ``\underline`` command.

.. code-block:: python

import matplotlib.pyplot as plt
plt.text(0.4, 0.7, r'This is $\underline{underlined}$ text.')
plt.text(0.4, 0.3, r'So is $\underline{\mathrm{this}}$.')
plt.show()
17 changes: 17 additions & 0 deletionslib/matplotlib/_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1770,6 +1770,7 @@ def csnames(group, names):
p.group = Forward()
p.operatorname = Forward()
p.overline = Forward()
p.underline = Forward()
p.overset = Forward()
p.placeable = Forward()
p.required_group = Forward()
Expand DownExpand Up@@ -1820,6 +1821,7 @@ def csnames(group, names):
+ p.required_group("value"))

p.overline <<= cmd(r"\overline", p.required_group("body"))
p.underline <<= cmd(r"\underline", p.required_group("body"))

p.overset <<= cmd(
r"\overset",
Expand All@@ -1843,6 +1845,7 @@ def csnames(group, names):
| p.underset
| p.sqrt
| p.overline
| p.underline
)

p.simple <<= (
Expand DownExpand Up@@ -2478,6 +2481,20 @@ def overline(self, s, loc, toks):
hlist = Hlist([rightside])
return [hlist]

def underline(self, s, loc, toks):
body = toks["body"]

state = self.get_state()
thickness = state.get_current_underline_thickness()

# Place underline below body (loosely based on node735).
kern = 3 * thickness
vlist = Vlist([Hlist([body]), Kern(kern), Hrule(state, thickness)])
vlist.shift_amount = kern + thickness / 2 + body.depth

hlist = Hlist([vlist])
return [hlist]

def _auto_sized_delimiter(self, front, middle, back):
state = self.get_state()
if len(middle):
Expand Down
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionslib/matplotlib/tests/test_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -129,6 +129,7 @@
r'$x \overset{f}{\rightarrow} \overset{f}{x} \underset{xx}{ff} \overset{xx}{ff} \underset{f}{x} \underset{f}{\leftarrow} x$', # github issue #18241
r'$\sum x\quad\sum^nx\quad\sum_nx\quad\sum_n^nx\quad\prod x\quad\prod^nx\quad\prod_nx\quad\prod_n^nx$', # GitHub issue 18085
r'$1.$ $2.$ $19680801.$ $a.$ $b.$ $mpl.$',
r'Matplotlib: $\underline{Plotting}$ $\underline{\mathrm{with}}$ Python', # GitHub issue 14235
]

digits = "0123456789"
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp