Skip to content

Use the right function to disable the offset #16239

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 1 commit into from

Conversation

vallsv
Copy link
Contributor

@vallsv vallsv commented Jan 16, 2020

PR Summary

This PR update the example from the documentation to use the proper function to avoid using scientific offset in the plot.

Relative to this discussion #16232

Closes #16232

Fill free to close this PR and the related issue if it do not fit.

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

@ImportanceOfBeingErnest
Copy link
Member

Interestingly,

 ax.plot(np.arange(2000, 2010), range(10))

does not result in any offset with current matplotlib. Hence this needs to change anyways for the whole paragraph to make sense.

So suppose it is

ax.plot(np.arange(20000, 20010), range(10))

instead. Then, using ax.get_xaxis().get_major_formatter().set_useOffset(False) does indeed get rid of the offset, just as currently described in that part.

Concerning the "multiplicative offset", another example can be added. E.g. if

ax.plot(np.linspace(0, 3e8, 301), range(301))

then adding ax.get_xaxis().get_major_formatter().set_scientific(False) will remove the "multiplicative offset".

The difference between the two is not well documented anywhere. So it would in addition make sense to add a respective paragraph in the ticks-and-ticklabels section of the text tutorial.

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.

I'm blocking this. set_scientific is not correct here. This is a misconception originating in poor docs. See linked PRs.

@vallsv
Copy link
Contributor Author

vallsv commented Jun 9, 2020

Thanks a lot. If you fix the matplotlib behavior in order to provide 2 independent concepts for offset and scientific notation, it is far better.

But if you only update the docstring, you only provide documentation which do not match the actual matplotlib behavior. So, do you plan to fix the behavior? Is there a related issue i can follow?

Thanks a lot.

@timhoffm
Copy link
Member

timhoffm commented Jun 9, 2020

Offsets and scientific notation are two independent concepts, and IMO work as they should. This is only a documentation issue. See #17590, #17592.

@vallsv
Copy link
Contributor Author

vallsv commented Jun 9, 2020

Definitely not. Else, disabling scientific notation should not be needed to disable the offset.

This said, i did not checked it again since January.

@vallsv
Copy link
Contributor Author

vallsv commented Jun 9, 2020

Oh, yes, in fact the issue was on my PR description: #16232

@timhoffm
Copy link
Member

timhoffm commented Jun 9, 2020

I've commented in #16232 on that.

@vallsv
Copy link
Contributor Author

vallsv commented Jun 9, 2020

I see, there is an offset and a factor. Thanks a lot for the clarification.

@vallsv vallsv closed this Jun 9, 2020
@QuLogic QuLogic modified the milestones: v3.3.0, unassigned Jul 9, 2020
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.

set_useOffset(False) is not working
5 participants