-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PowerNorm().__call__ doesn't work with scalar input value #4053
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
Comments
Can you provide a bit for context to what is going on here? It is best if you can include an example that can be copy-paste run (http://sscce.org/) and the traceback produced. |
Python 2.7.6 =================== Sample starts here ============= #!/usr/bin/env python
import matplotlib
import matplotlib.pyplot
min,max = (1,100)
cm = matplotlib.pyplot.get_cmap('jet')
cNorm0 = matplotlib.colors.Normalize(vmin=min, vmax=max)
cNorm1 = matplotlib.colors.LogNorm(vmin=min, vmax=max)
cNorm2 = matplotlib.colors.PowerNorm(1.,vmin=min, vmax=max,clip=True)
scalarMap0 = matplotlib.cm.ScalarMappable(norm=cNorm0, cmap=cm)
scalarMap1 = matplotlib.cm.ScalarMappable(norm=cNorm1, cmap=cm)
scalarMap2 = matplotlib.cm.ScalarMappable(norm=cNorm2, cmap=cm)
value = 50.
print "min,max",min,max
print "RGB for Normalize(50)", scalarMap0.to_rgba(value)
print "RGB for LogNorm(50)", scalarMap1.to_rgba(value)
print "RGB for PowerNorm(50)", scalarMap2.to_rgba([value])[0]
print "RGB for PowerNorm(50)", scalarMap2.to_rgba(value) ============== Sample ends here ================== Output:
[TAC edited to add markup] |
Which version of matplotlib? I could have sworn we fixed this. By the way, with my matplotlib from (slightly old) trunk and numpy version
So, I don't know if this is a weird interaction or not with numpy. On Fri, Jan 30, 2015 at 1:35 AM, olegarch [email protected] wrote:
|
have a fix in + extended the tests. At some point we should go through and simplify all of that code to use arrays filled with nans internally rather than masked arrays. |
@olegarch Thanks! If possible can you confirm that this fixes the issue for you? |
It works. Thanks! |
@olegarch Good. This fix will be in 1.4.3 (tagged a release candidate last night, should do full release next weekend). |
@olegarch Good to hear. |
result[value<0] = 0; #fails if value is scalar
The text was updated successfully, but these errors were encountered: