Skip to content
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

Define \mathdefault as a noop in the usetex preamble. #15695

Merged
merged 2 commits into from
Dec 13, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 14, 2019

This avoids having to strip out \mathdefault (a non-existent latex
command) before generating usetex strings, as that's brittle on tickers
-- the global usetex flag may change after the ticker is instantiated.

Closes #10317.

(Note that we claim that the semantics of \mathdefault is "match the non-math font", but in usetex mode we previously just stripped it out anyways; making TeX actually use the non-math font in math would be... trickier.)

PR Summary

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

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.

This should get documentation:

@anntzer
Copy link
Contributor Author

anntzer commented Nov 17, 2019

This is already documented in https://matplotlib.org/devdocs/tutorials/text/mathtext.html (look up \mathdefault there).

Added comments, and also refactored the preamble-getting in to avoid duplicating that between make_tex and make_tex_preview.

@jklymak
Copy link
Member

jklymak commented Dec 12, 2019

This looks good, but can this also get a test for the breaking case so it doesn't break again?

This avoids having to strip out \mathdefault (a non-existent latex
command) before generating usetex strings, as that's brittle on tickers
-- the global usetex flag may change after the ticker is instantiated.
@anntzer
Copy link
Contributor Author

anntzer commented Dec 12, 2019

sure... done

@jklymak jklymak added this to the v3.3.0 milestone Dec 13, 2019
@jklymak jklymak merged commit 508f21f into matplotlib:master Dec 13, 2019
@jklymak
Copy link
Member

jklymak commented Dec 13, 2019

Feel free to re-milestone and back port if we think thats important....

@anntzer anntzer deleted the mathdefault branch December 13, 2019 20:51
@pyZerrenner
Copy link

Thanks for fixing this! This solution is much simpler than my idea :)

@anntzer
Copy link
Contributor Author

anntzer commented Dec 13, 2019

You are welcome :)

@tacaswell tacaswell modified the milestones: v3.3.0, v3.2.2 Apr 28, 2020
@tacaswell
Copy link
Member

@meeseeksdev backport to v3.2.x

@lumberbot-app
Copy link

lumberbot-app bot commented Apr 28, 2020

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 508f21fb42d172201e5048b701fa13e16868bac7
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #15695: Define \\mathdefault as a noop in the usetex preamble.'
  1. Push to a named branch :
git push YOURFORK v3.2.x:auto-backport-of-pr-15695-on-v3.2.x
  1. Create a PR against branch v3.2.x, I would have named this PR:

"Backport PR #15695 on branch v3.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Apr 28, 2020
Define \mathdefault as a noop in the usetex preamble.

Conflicts:
   lib/matplotlib/ticker.py
      change of a near-by conditional from np.abs -> abs caused
      conflict
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.

Setting plt.rc('text', usetex=True) after ticker.ScalarFormatter(useMathText=True) causes Error
6 participants