Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add \underline to mathtext #15624

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 360 commits into from
Closed

Conversation

wesbarnett
Copy link

@wesbarnett wesbarnett commented Nov 7, 2019

PR Summary

Implements #14235 to add \underline to mathtext.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@pprasha
Copy link

pprasha commented Mar 22, 2020

let me take a look

@jklymak jklymak marked this pull request as draft July 23, 2020 03:22
anntzer and others added 25 commits September 12, 2021 14:02
Make type lists fit in a single line.  A strict reading suggests that
all types should be separated with ` or ` rather than a comma, but
avoiding a backslash continuation seems more useful.

Also, *s* can also be a str.
Fix validate_markevery docstring markup.
This was introduced in 2015 when support for running nose tests via
`setup.py test` was removed. We do not need to explicitly tell people
anymore that this is not possible.
Remove dummy test command from setup.py
They are instead replaced by slightly roundabout ways to get hold of the
same objects (CompilerError, CCompiler).

Only distutils.sysconfig remains; we should investigate whether the
stdlib's sysconfig is a satisfactory replacement for it.
As noted in the module docstring, there is a confusion between using a
generic default MarkerStyle (empty) and the artist-specific one (e.g.
scatter plots use `rcParams["scatter.marker"]`).  Fortunately, direct
construction of MarkerStyles (especially of empty ones) is hardly ever
needed, so we can just make the parameter required.
…plate

Fix typo in template of current dev-docs
Deprecate support for no-args MarkerStyle().
As for other APIs, this is less likely to be confused with the None
object.
Unlike the Agg renderer, the Cairo renderer exists forever and is at the
DPI when the figure was created. This needs to be updated before drawing
or things in physical sizes (e.g., text or line widths) will be the
wrong size.
Otherwise, `FigureCanvasBase.get_width_height` returns a size scaled
down by the current pixel ratio, even though the DPI is not scaled up.
This causes the saved figure to be cropped.
set_dashes does not support offset=None anymore.
@wesbarnett
Copy link
Author

@QuLogic you can remove the "work in progress" tag for this. It's ready to be reviewed. Thanks!

@@ -2915,6 +2922,26 @@ def overline(self, s, loc, toks):
hlist = Hlist([rightside])
return [hlist]

def underline(self, s, loc, toks):
(body,), = toks
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for your perseverance with this. Is it possible the test coverage could hit these missing lines?

@jklymak
Copy link
Member

jklymak commented Nov 8, 2021

@wesbarnett popping to draft until the rebase gets figured out.... You may need to follow instructions at https://discourse.matplotlib.org/t/default-branch-renamed-with-minor-edit-to-history/22367/2 Thanks!

@tfpf
Copy link
Contributor

tfpf commented Aug 12, 2022

There haven't been any updates here for a while. Unless I am mistaken, this is not extremely hard to implement. The details are in node 735 of TeX, but it doesn't look that's what's happening here?

@tfpf
Copy link
Contributor

tfpf commented Aug 14, 2022

I think mimicking TeX's behaviour is straightforward. Not sure how exactly overline works, but TeX puts a space between the text and the underline equal to thrice the thickness of the underline (even if the text has depth). Just adding vertical kerning should work?

I can open another pull request to implement it if that's okay.

@timhoffm
Copy link
Member

I think mimicking TeX's behaviour is straightforward. Not sure how exactly overline works, but TeX puts a space between the text and the underline equal to thrice the thickness of the underline (even if the text has depth). Just adding vertical kerning should work?

I can open another pull request to implement it if that's okay.

I'm not a TeX expert, but if you have a straight-forward solution, please go ahead and open a new PR.

@tfpf tfpf mentioned this pull request Aug 14, 2022
5 tasks
@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jun 30, 2023
@melissawm
Copy link
Member

It looks like there are two PRs trying to solve the same issue here - this one and #23616. Any chance @wesbarnett and @tfpf could team up or review each other's work so this feature can move forward? Thanks!

@rcomer
Copy link
Member

rcomer commented Jul 4, 2023

Looks like @tfpf opened the other PR because this one had stalled....

@tfpf
Copy link
Contributor

tfpf commented Jul 4, 2023

Initially, I though this approach could be improved by applying the make_under procedure of TeX (node 735 in TeX: the Program). To my utter surprise, wesbarnett's code (from here) and the TeX code (from #23616) produce the exact same images! Unless I have terribly messed something up, the PNG files are identical, byte for byte; the SVG files are also identical, at least visually.

w
w

import matplotlib.pyplot as plt
fig = plt.figure()
plt.text(.5, .5, r'$\underline{ul}$', size=50)
plt.axhline(.5)
plt.savefig('s.svg')
plt.savefig('p.png')
plt.show()

Note that the SVG and PNG backends render the image differently. I got stuck here, and documented it in #23763. Still unable to figure out why that happens.

@wesbarnett
Copy link
Author

My PR is so far off with main at this point, I'm happy to close this as a duplicate of #23616. (My implementation was basically copying the overline functionality and making a few adjustments for it to be used as an underline.

@wesbarnett wesbarnett closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.