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

Autoscale in hist() with step and log #159

Closed
ddale opened this issue Jun 20, 2011 · 3 comments
Closed

Autoscale in hist() with step and log #159

ddale opened this issue Jun 20, 2011 · 3 comments

Comments

@ddale
Copy link
Contributor

ddale commented Jun 20, 2011

Original report at SourceForge, opened Tue Jun 22 07:58:14 2010

The autoscale seems to be broken in trunk in this example:

from pylab import *
hist(rand(100),bins=20,histtype="step",log=1)

SourceForge Comments

On Wed Aug 4 10:24:05 2010, None wrote:

Sorry for not being explicit enough. The lower y-limit was previously set to a value closer to the lowest non-zero bin, and not 1E-100.

That being said, the behaviour in rev 8623 is actually sane again.

On Tue Jul 6 15:17:38 2010, mdboom wrote:

Can you be more specific about what you would have expected to see?

On Tue Jun 29 08:05:07 2010, None wrote:

Uploaded the plot that I get here, from rev 8475.

On Thu Jun 24 10:51:32 2010, mdboom wrote:

In what way is it broken? The axes appears to contain all of the data. Some of the lines are right under the axes line at the top, but that is expected behavior. If you want some "padding", that would have to be added manually.

SourceForge History

  • On Tue Jun 29 03:22:58 2010, by None: File Added: 378710: image.png
@dmcdougall
Copy link
Member

Here's a script plotting steps and bars:

In [1]: import matplotlib

In [2]: matplotlib.use('agg')

In [3]: import matplotlib.pyplot as plt

In [4]: fig = plt.figure()

In [5]: ax = fig.add_subplot(2, 1, 1)

In [6]: import numpy as np

In [7]: ax.hist(np.random.rand(100), histtype='step', log=1)
Out[7]: 
(array([10, 12,  2,  8, 11,  7, 12, 15, 11, 12]),
 array([ 0.00352264,  0.10181859,  0.20011454,  0.2984105 ,  0.39670645,
        0.4950024 ,  0.59329835,  0.6915943 ,  0.78989025,  0.8881862 ,
        0.98648216]),
 <a list of 1 Patch objects>)

In [8]: ax2 = fig.add_subplot(2, 1, 2)

In [9]: ax2.hist(np.random.rand(100), log=1)
Out[9]: 
(array([11,  8, 13,  6,  9,  6, 16, 10, 12,  9]),
 array([ 0.00454384,  0.10397154,  0.20339924,  0.30282694,  0.40225465,
        0.50168235,  0.60111005,  0.70053775,  0.79996545,  0.89939315,
        0.99882086]),
 <a list of 10 Patch objects>)

In [10]: fig.savefig('hists.png')

In [11]: !open hists.png

And here's sample output:

output

I don't think there's anything wrong. As @mdboom pointed out in the original email, the axes contain all the data. Perhaps the in the case where histtype='step' we could handle the trailing bin edges better, by setting ylim such that the y-axis in each plot is the same, but I'd think that was for eye-candy?

I think this issue can probably be closed, but I'll leave it open for a few days just in case I'm missing something.

@pelson
Copy link
Member

pelson commented Sep 23, 2012

While the ranges are different, neither look "broken". We don't have an end user for this one, so I would second your assertion that this can be closed.

@dmcdougall
Copy link
Member

@pelson Thanks. I thought as much.

anntzer added a commit that referenced this issue Dec 14, 2019
Raise an ValueError when Axes.pie accepts negative values #15923
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants