Skip to content

Search for minus of any font size to get height of tex result #17578

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 3 commits into from
Aug 4, 2020

Conversation

adambrown1
Copy link
Contributor

PR Summary

When searching for minus symbols in tex output, to treat them as a special case, do so for any font size not just font size 10. Minus is glyph zero of the font cmsyXX (XX being the font size).

This ensures that negative numbers have correct alignment when using tex, whatever the font size being used. This closes #17574.

The same example in the issue now gives the correct output:

from matplotlib import pyplot as plt
fig = plt.figure(dpi=300)
plt.rc('text', usetex=True)
ax = fig.add_subplot(1,2,1)
plt.plot((-7.,0.,7.), (-1.,0.,1.), 'r-')
plt.rc('text', usetex=True)
ax = fig.add_subplot(1,2,2)
plt.plot((-7.,0.,7.), (-1.,0.,1.), 'r-')
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.show()

working_example_17574

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

When searching for minus symbols in tex output, to treat them as a 
special case, do so for any font size not just font size 10. Minus is 
glyph zero of the font cmsyXX (XX being the font size).
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Doc failure is unrelated, see #17595.

@QuLogic
Copy link
Member

QuLogic commented Jun 9, 2020

This looks good, but can you update the test (test_minus_no_descent) to also exercise this case? Probably just parametrize it over font size.

@tacaswell tacaswell added this to the v3.4.0 milestone Jun 17, 2020
@QuLogic QuLogic merged commit 1df9efc into matplotlib:master Aug 4, 2020
@QuLogic
Copy link
Member

QuLogic commented Aug 4, 2020

Thanks @adambrown1! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertical alignment of tick labels containing minus in font size other than 10 with usetex=True
5 participants