-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Error on colorbar #12445
Comments
Can you make a complete example: http://sscce.org |
ExampleUsing Jupyter notebook %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
### Create a random array
a = np.random.rand(100, 100)
plt.imshow(a)
plt.colorbar();
##This second part will give error for the colorbar
### Create a boolean array
b = a > .5
print(b.dtype) # bool
plt.imshow(b) #This works
plt.colorbar() #TypeError even though it worked with older version of matplotlib/numpy |
sorry closed it accidentally. |
Just to mention, |
Not sure if we support boolean arrays, but colorbar hasn't worked with this since at least 2.2.0. Suggest you cast to float or int. |
fwiw this was already discussed in #8820. |
Yes, true. Upon casting to float or int, the colorbar works properly. So I believe there is no plan to support colorbar for either boolean or categorical data. |
Categorical would be a big change. Boolean would probably be easier, but frankly it’s probably better to defer to numpy who are not allowing Boolean math any longer. |
Let's close the issue here as it was already discussed less than a year ago and we decided to defer to numpy's choice. |
Bug report
Bug summary
I get an error on calling the colorbar() function that was working perfectly with older version of matplotlib, numpy
I suspect, this TypeError is rasied when calling the plt.colorbar() method on an image of dtype boolean.
Code for reproduction
Actual outcome
Plots the image, but gives following error with plt.colorbar()
Expected outcome
Matplotlib version 3.0
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineusing Anaconda
The text was updated successfully, but these errors were encountered: