Thanks to visit codestin.com
Credit goes to github.com

Skip to content

matplotlib stepfilled histogram breaks at the value 10^-1 on xubuntu #5885

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
kxf010 opened this issue Jan 20, 2016 · 14 comments
Closed

matplotlib stepfilled histogram breaks at the value 10^-1 on xubuntu #5885

kxf010 opened this issue Jan 20, 2016 · 14 comments

Comments

@kxf010
Copy link

kxf010 commented Jan 20, 2016

Why is it that when the code in the text file is run through python the graph seems to break down at 10^-1 on the y-axis?
hist.txt

from pylab import *

bins = [+0.000e+00,+1.000e+00,+2.000e+00,+3.000e+00,+4.000e+00,+5.000e+00]
wght = [[+3.000e-02,+7.0e-02,+3.0e-01,+5.0e-01,+8.0e-01]]

hist([ bins[:-1] for i in range(len(wght)) ], bins=bins, weights=wght, histtype="stepfilled", log=True )

ylim(bottom=0.01); ylim(top=1.0)

savefig("./output.pdf")

What it should look like: https://gyazo.com/b57ad2c8fb67580caf7e6296f33fa86e

What it actually looks like: https://gyazo.com/22470f9d7c9a46316061ca1c7874ac33

@tacaswell
Copy link
Member

Can you please include the code in-line? What exactly do you mean by 'break down'?

@kxf010
Copy link
Author

kxf010 commented Jan 20, 2016

I meant to add pictures, here they come.

@kxf010
Copy link
Author

kxf010 commented Jan 20, 2016

By "break-down" I mean the graph doesn't plot past 10^-1 on the y-axis

@QuLogic
Copy link
Member

QuLogic commented Jan 20, 2016

With what version? The code you provided works fine with 1.4.3 and 1.5.0. (And on a side note, you shouldn't really use pylab.)

@kxf010
Copy link
Author

kxf010 commented Jan 20, 2016

It looks like the version on Windows is 1.4.3 and Xubuntu's is 1.3.1. I downloaded the 1.5.1 and re ran the code and the graph is the same. Also instead of getting 1.5.1 when I execute this, python -c 'import matplotlib; print(matplotlib.version)' , I get 1.3.1 so for some reason the version hasn't changed.

@kxf010
Copy link
Author

kxf010 commented Jan 20, 2016

@QuLogic Why do you recommend against the use of pylab?

@WeatherGod
Copy link
Member

pylab shouldn't be used for scripting. It really should only be for
interactive situations where you want conciseness. We have been working on
getting rid of scripting examples of pylab, because "explicit is better
than implicit" and "namespaces are a honking good idea". The other fun
thing that happens is that np.min(), np.max(), np.any() and np.all()
overrides the built-in min(), max(), any() and all(), which can cause very
subtle issues in some edge cases.

On Wed, Jan 20, 2016 at 6:20 PM, kxf010 [email protected] wrote:

@QuLogic https://github.com/QuLogic Why do you recommend against the
use of pylab?


Reply to this email directly or view it on GitHub
#5885 (comment)
.

@tacaswell
Copy link
Member

They are not even that edge:

In [26]: min((i for i in range(3)))
Out[26]: 0

In [27]: import numpy as np

In [28]: np.min((i for i in range(3)))
Out[28]: <generator object <genexpr> at 0x7fcd58ccfca8>

or more fun

In [32]: bool(np.all((0 for j in range(5))))
Out[32]: True

@WeatherGod
Copy link
Member

We really should get around to taking advantage of the single-dispatch
system to register those functions for array-like inputs and get pylab to
not clobber the builtins.

On Wed, Jan 20, 2016 at 8:01 PM, Thomas A Caswell [email protected]
wrote:

They are not even that edge:

In [26]: min((i for i in range(3)))
Out[26]: 0

In [27]: import numpy as np

In [28]: np.min((i for i in range(3)))
Out[28]: <generator object at 0x7fcd58ccfca8>

or more fun

In [32]: bool(np.all((0 for j in range(5))))
Out[32]: True


Reply to this email directly or view it on GitHub
#5885 (comment)
.

@kxf010
Copy link
Author

kxf010 commented Jan 21, 2016

Thanks! Also, are there any known workarounds for when an older version is in use?

@WeatherGod
Copy link
Member

yeah, don't use pylab... (actually, there is a real workaround, but it is
extremely convoluted. We implemented it in matplotlib for certain internal
uses, but perhaps it makes sense to export it somehow?

On Thu, Jan 21, 2016 at 9:23 AM, kxf010 [email protected] wrote:

Thanks! Also, are there any known workarounds for when an older version is
in use?


Reply to this email directly or view it on GitHub
#5885 (comment)
.

@tacaswell
Copy link
Member

See https://stackoverflow.com/questions/18774388/re-import-aliased-shadowed-python-built-in-methods for how to get the original functions back.

However, this has been side tracked from the original bug. What version of mpl are you using?

@kxf010
Copy link
Author

kxf010 commented Jan 26, 2016

I'm using both 1.5.1 and 1.3.1. My goal is to try and get a working bit of code on 1.3.1 so users will be able to use the code without having to update matplotlib as 1.3.1 is the latest in Ubuntu's Software Center(USC). For some reason it hasn't actually updated to 1.5.1 on the USC.

@tacaswell
Copy link
Member

It looks like there is not a direct work-around with 1.3.1. The best course of action would be to do your histograming via numpy

bins, edges = np.histogram(data)

and then ship a version of the code in #643 (comment) to do the plotting.

We definitely will not be releasing a 1.3.2.

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

4 participants