Skip to content

Inline ScalarFormatter._formatSciNotation. #18506

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
Sep 18, 2020
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 17, 2020

It's only used in one place, in a tiny function, and doesn't have a
particularly intuitive name, so it's actually easier to follow the logic
by having it all in one place. Moreover the implementation can be
greatly simplified by separately computing and formatting the mantissa
and the exponent, rather than trying to parse the locale-dependent
result of the formatting of the entire number.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
Copy link
Member

jklymak commented Sep 18, 2020

The doc error looks real to me...

It's only used in one place, in a tiny function, and doesn't have a
particularly intuitive name, so it's actually easier to follow the logic
by having it all in one place.  Moreover the implementation can be
greatly simplified by separately computing and formatting the mantissa
and the exponent, rather than trying to parse the locale-dependent
result of the formatting of the entire number.
@QuLogic QuLogic merged commit 6bd5d9b into matplotlib:master Sep 18, 2020
@QuLogic QuLogic added this to the v3.4.0 milestone Sep 18, 2020
@anntzer anntzer deleted the fsn branch September 18, 2020 08:28
StefRe added a commit to StefRe/matplotlib that referenced this pull request Dec 29, 2021
scottshambaugh pushed a commit to scottshambaugh/matplotlib that referenced this pull request Jan 6, 2022
@vpicouet
Copy link

Hello,
I used to use _formatSciNotation to convert number to scienctific notation (as mentionned here https://stackoverflow.com/questions/25750170/show-decimal-places-and-scientific-notation-on-the-axis-of-a-matplotlib-plot ):
fmt = mticker.FuncFormatter(lambda x, pos: "${}$".format(mticker.ScalarFormatter(useOffset=False, useMathText=True)._formatSciNotation("%1.10e" % np.round(x, 5))))
What is the best way to do it now?
Thanks for your help!

@jklymak
Copy link
Member

jklymak commented Apr 25, 2022

@vpicouet please ask usage questions at discourse.matplotlib.org. However this is as a private method so it was not meant to be used by downstream users. You could look at the source and copy it.

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.

5 participants