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

SymLogNorm returns 'inf' and 'nan' when given negative vmin as __init__ argument #3321

Closed
wackywendell opened this issue Jul 29, 2014 · 2 comments
Milestone

Comments

@wackywendell
Copy link
Contributor

When SymLogNorm (from matplotlib.colors) is given a vmin argument that is negative, it returns infs and nans, when it should be able to handle negative values. If you omit the vmin argument and instead give it data that goes negative, it will automatically set a negative vmin and work fine.

See this notebook, which comes from this gist.

Here is the relevant portion:

data = array([-1, -0.2, 0, 0.01, 0.2, 4])

norm1 = SymLogNorm(0.1, vmin=-1, vmax=40)
norm2 = SymLogNorm(0.1, vmax=40)

print(norm1(data))
print(norm2(data))

Output:

[-inf -inf  nan  inf  inf  inf]
[ 0.          0.14046408  0.33902607  0.35283281  0.53758806  0.79904133]

It seems that the issue may have to do with incorrectly setting _lower and _upper:

print(norm1.vmin, norm1.vmax, norm1._lower, norm1._upper)
print(norm2.vmin, norm2.vmax, norm2._lower, norm2._upper)

Output:

-1 40 0 0
-1.0 40 -0.388456179986 0.757344125398
@tacaswell tacaswell added this to the v1.4.x milestone Jul 29, 2014
@tacaswell
Copy link
Member

Can you test with 1.4.0rc2?

I can not reproduce this on (almost) current master. Please ping me to re-open if you still get this with the new version.

@wackywendell
Copy link
Contributor Author

Good point; I just tested on master, and the behavior is as expected. Case closed.

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

2 participants