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

Skip to content

Issue with plotting zeros in log space #4049

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
astrofrog opened this issue Jan 29, 2015 · 7 comments · Fixed by #4050
Closed

Issue with plotting zeros in log space #4049

astrofrog opened this issue Jan 29, 2015 · 7 comments · Fixed by #4050

Comments

@astrofrog
Copy link
Contributor

The following simple example shows an issues with zero values when calling loglog:

import matplotlib.pyplot as plt

nu = [1e2, 1e3, 1e4, 1e5, 1e6, 1e7]
fnu = [1, 1e-30, 1e-45, 0., 0., 0.]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.loglog(nu, fnu, color='blue')
fig.savefig('mpl.png')

The output is:

mpl

Of course, zero is undefined in log space, but I don't understand why it defaults to plotting a value of 0.1 instead. Doing:

fnu = [1, 1e-30, 1e-45, np.nan, np.nan, np.nan]

Does the right thing on the other hand. So maybe the best solution is to replace 0 values by np.nan inside loglog?

I am using matplotlib 1.5.x with Python 3.4.

@mdboom
Copy link
Member

mdboom commented Jan 29, 2015

Puzzling -- the values are masked out in the log scalar and have been for years. Something else is going wrong here. Investigating.

@mdboom mdboom added this to the v1.5.x milestone Jan 29, 2015
@mdboom mdboom self-assigned this Jan 29, 2015
@mdboom
Copy link
Member

mdboom commented Jan 29, 2015

First bad commit is 91725d8 (only affects master). Looking into a solution now.

@tacaswell
Copy link
Member

I thought I fixed this recently....

@tacaswell
Copy link
Member

#4008

@astrofrog
Copy link
Contributor Author

Great, thanks! That does indeed seem to be the same issue.

@tacaswell
Copy link
Member

This is a duplicate of #3998

@mdboom
Copy link
Member

mdboom commented Jan 29, 2015

Sorry I missed that duplicate. I have a few comments about the solution over at #4008...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants