-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
New featurekeepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Actiontopic: units and array ducktypes
Description
Problem
Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units.
Proposed Solution
Here's a short example that should work fine using units, but which currently fails. The use of datetime is a bit contrived, but I chose it to avoid a third party package. For a more realistic real-world example see astropy/astropy#11306.
from datetime import datetime
import matplotlib.colors as mcolor
import matplotlib.pyplot as plt
data = [[datetime.now(), datetime.now()],
[datetime.now(), datetime.now()]]
fig, ax = plt.subplots()
im = ax.imshow(data, norm=mcolor.LogNorm())
fig.colorbar(im)
plt.show()
This fails in
File "/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_axes.py", line 5586, in imshow
im.set_data(X)
File "/Users/dstansby/github/matplotlib/lib/matplotlib/image.py", line 700, in set_data
raise TypeError("Image data of dtype {} cannot be converted to "
TypeError: Image data of dtype object cannot be converted to float
Metadata
Metadata
Assignees
Labels
New featurekeepItems to be ignored by the “Stale” Github ActionItems to be ignored by the “Stale” Github Actiontopic: units and array ducktypes