Skip to content

ENH:made default tick formatter to switch to scientific notation earlier #14832

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 5 commits into from
Aug 22, 2019
Merged

ENH:made default tick formatter to switch to scientific notation earlier #14832

merged 5 commits into from
Aug 22, 2019

Conversation

sameshl
Copy link
Contributor

@sameshl sameshl commented Jul 17, 2019

The default tick formatter switches to scientific notation only for very small values,
but there is a range of slightly bigger values where scientific notation would be better too.

changed the formatter limits from -7,7 to -5,5

closes #14800

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

The default tick formatter switches to scientific notation only for very small values,
but there is a range of slightly bigger values where scientific notation would be better too.

changed the formatter limits from -7,7 to -5,5

closes #14800
@jklymak
Copy link
Member

jklymak commented Jul 17, 2019

This prob needs an API change note, and you probably need to edit the default .matplotlibrc?

@jklymak jklymak added this to the v3.2.0 milestone Jul 17, 2019
Add note in api section and changed new defaults in matplotlibrc
@@ -1157,3 +1157,8 @@ result in undefined behavior. It now throws a `ValueError`.

The signature of the (private) ``Axis._update_ticks`` has been changed to not
take the renderer as argument anymore (that argument is unused).

Reduced default value of `axes.formatter.limits`
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, should have been clear about where this goes. it gets a new file in doc/api/next-api-changes/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jklymak I am not able to exactly understand the naming convention of the files in doc/api/next-api-changes/. For eg, in 2019-05-08-AL.rst what exactly does AL mean?

Copy link
Member

Choose a reason for hiding this comment

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

AL are the authors initials. Which is a bit mysterious, i.e. in that case "Antony Lee".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the date is the date of modification? Right?

Copy link
Member

@jklymak jklymak Jul 18, 2019

Choose a reason for hiding this comment

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

Yes; rough is fine.

Moved api change note from prev_api_change/api_changes/3.1.0.rst to next_api_changes/2019-07-18-SL.rst
@timhoffm
Copy link
Member

There are two failing image comparison tests because of the change. How do we want to handle these?

I propose to set the defaults back to -7, 7 for these tests. It's not worth or necessary regenerating the images.

@sameshl
Copy link
Contributor Author

sameshl commented Jul 19, 2019

I propose to set the defaults back to -7, 7 for these tests

@timhoffm Do you mean revert the change in matplotlibrc to -5, 5 ?

@timhoffm
Copy link
Member

Yes, at the beginning of these two tests, just add

# use former defaults to match existing baseline image
plt.rcParams['axes.formatter.limits'] = -7, 7

Note: There's no need to revert that setting at the end of the test because each test starts with the default settings.

@sameshl
Copy link
Contributor Author

sameshl commented Jul 21, 2019

I see. I made the required changes. Thanks for the info @timhoffm!

@timhoffm
Copy link
Member

Sorry, I may not have been clear enough.

I don't think we should apply this to all image comparison tests, but only on a case-by-case basis in the actual test functions where it's necessary to get the the tests pass without regenerating the baseline images (IIRC that have been two tests).

@sameshl
Copy link
Contributor Author

sameshl commented Jul 22, 2019

Sorry, I think I misunderstood you. But thank you for helping me out. 👍 I think I have made the required changes

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

The code looks fine, but I don't know about the defaults change.

@QuLogic QuLogic requested a review from tacaswell July 25, 2019 08:36
@tacaswell
Copy link
Member

Seems reasonable, but has anyone thought about what this does to large numbers? We might want to have asymmetric thresholds.

@timhoffm
Copy link
Member

@tacaswell Good point. Maybe -5, 6? 5000000 is not quite readable anymore either.

@sameshl
Copy link
Contributor Author

sameshl commented Aug 1, 2019

@timhoffm I think -5, 6 would be appropriate. I can make that change

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.

Blocking to prevent merge before the large-number limit is resolved.

We have a lot of approvals for the current state of -5, 5. But I would prefer -5, 6. Do we agree on that?

@jklymak
Copy link
Member

jklymak commented Aug 6, 2019

... piling on: It'd be nice for a test w the new limits. It would also clarify the new behaviour and why this limit is better, because otherwise I'm not sure I follow.

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.

My issues have been addressed. We need a second re-approval.

@jklymak What exactly would you like to test. I wouldn‘t want to create an image for this.

@timhoffm
Copy link
Member

ping @jklymak do you need additional tests?

@jklymak jklymak self-requested a review August 12, 2019 20:18
Reduced default value of `axes.formatter.limits`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Changed the default value of `axes.formatter.limits` from -7, 7 to -5, 6 for better readability.
Copy link
Member

Choose a reason for hiding this comment

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

@sameshl If you get a chance could you add a .. plot example to the API change note? It greatly helps people who are skimming the release note to understand the change!

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

Modulo an example plot in the API change note.

@sameshl
Copy link
Contributor Author

sameshl commented Aug 13, 2019

@tacaswell I will update api note with the .. plot example by tomorrow

@tacaswell tacaswell merged commit ac0a423 into matplotlib:master Aug 22, 2019
@tacaswell
Copy link
Member

I will open a PR with the example, merged to keep things moving.

Thanks @sameshl !

@sameshl sameshl deleted the tick_formatter_limits branch August 23, 2019 04:34
@sameshl
Copy link
Contributor Author

sameshl commented Aug 26, 2019

Thanks for taking up the example @tacaswell !

@tacaswell
Copy link
Member

Done in #15137

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.

default tick formatter could switch to scientific notation earlier
7 participants