Skip to content

plt.hist does not obey the hist.bins rcparams #7356

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
anntzer opened this issue Oct 27, 2016 · 5 comments
Closed

plt.hist does not obey the hist.bins rcparams #7356

anntzer opened this issue Oct 27, 2016 · 5 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Oct 27, 2016

2.0b4 and master

import matplotlib as mpl
from matplotlib import pyplot as plt
import numpy as np

mpl.rcdefaults()
mpl.rcParams["hist.bins"] = "auto"

np.random.seed(1)
x = np.random.rand(1000)
n0, b0, p0 = plt.hist(x)
n1, b1, p1 = plt.hist(x, "auto")
print(n0)
print(n1)
plt.show()

The first histogram has 10 bins, the second one has 11 bins.

Note that this does not affect calling the hist method on an explicitly created Axes object.

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Oct 27, 2016
@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Oct 27, 2016
@tacaswell
Copy link
Member

We just need to re-run boilerplate.py

@anntzer
Copy link
Contributor Author

anntzer commented Oct 27, 2016

Looking at the links at the top of boilerplate.py it seems that the reasons for its existence (rather than dynamically generating wrapper functions at import time) is

  • the __name__ of functions was not writable in Python 2.2, and
  • there was no way to preserve the signatures of the wrappees (until the introduction of function signature objects in Python 3.3).

The first point is obviously no longer a problem. Regarding the second one, I see that IPython carries its own backport of Signature objects (https://github.com/ipython/ipython/blob/master/IPython/utils/_signatures.py), so it should be possible to at least display the correct signature within IPython (python2) even using dynamically generated wrappers.

Or we could (very reasonably) just wait until Py2 support is dropped to get rid of boilerplate.py; in such a case, it may make sense to integrate the running of boilerplate.py into python setup.py build, so that we don't forget it?

@tacaswell
Copy link
Member

There is an open issue for checking that we have run boiler plate in the tests #3701

#3587 and #2736 are two half-started attempts to generate pyplot at run time. #4488 is a pass at a helper decorator for the same purpose.

There was some concern about the generating at runtime approach messing with static code analysis tools (like pycharm's auto complete / suggestions).

We do currently use their signature backport, but only if we are already in an IPython sessions (which we check by seeing if IPython is already in the sys.modules).

@anntzer
Copy link
Contributor Author

anntzer commented Oct 27, 2016

Given that pycharm even supports PEP484 semantics for type annotations (https://www.jetbrains.com/help/pycharm/2016.1/type-hinting-in-pycharm.html), I would be amazed that it is not able to support signature objects...

@NelleV
Copy link
Member

NelleV commented Nov 10, 2016

This is fixed in both master and v2.x as of yesterday.

@NelleV NelleV closed this as completed Nov 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

No branches or pull requests

3 participants