You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Showing np.uint16 images of the form (h,w,3) is broken #2499
import matplotlib.pyplot as plt
import numpy as np
A = np.array([np.arange(256,dtype=np.uint16) for _ in xrange(256)])
B = (A<<8)+(255*np.random.random(A.shape)).astype(np.uint16)
B = np.dstack([B,B,B])
plt.imshow(B)
plt.show()
This results in random bits.
The problem is in file lib/matplotlib.cm.py: the conversion to np.uint8 assumes that the input is in 0..1 format.
Activity
tacaswell commentedon Oct 6, 2013
To be fair, the docs (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.imshow) only claim to support float or uint8 so I would not call this broken.
luispedro commentedon Oct 7, 2013
Then, maybe the real bug is that it doesn't raise an exception :)
It's certainly surprising behaviour.
BUG Raise exception for invalid input
tacaswell commentedon Nov 29, 2013
@luispedro Can you make a PR with that fix?
BUG Raise exception for invalid input
BUG Raise exception for invalid input
BUG Raise exception for invalid input
MNT: improve image array argument checking in to_rgba. Closes matplot…
MNT: improve image array argument checking in to_rgba. Closes matplot…
Merge pull request #6122 from efiring/update_2632_2
tacaswell commentedon Mar 7, 2016
@luispedro Thanks, sorry this took so long to get resolved.