-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Imshow breaks if given a unyt_array input #18077
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
Operations on the x and y axis are supported as units. Zdata is not, and never has been. It's not clear what the goal of doing so would be. I think it's possible we should be trying to downcast to an np array here, which I assume is all you would like. |
What happens w/ |
import unyt
import numpy as np
from matplotlib import pyplot as plt
arr = unyt.unyt_array(np.random.normal(0, 1, 16**2).reshape(16, 16), "g/cm**3")
fig, ax = plt.subplots()
im = ax.pcolormesh(arr)
fig.colorbar(im)
fig.savefig("/tmp/pcolor_unyt.png") So yeah, it doesn't make a difference with respect to simply using a raw numpy array directly, but what I want to point out is that imshow in particular is inconsistent with the other 2d functions I've tried here.
I for one think this would be quite useful, but that's going well beyond this bug report. |
So imshow just needs to precondition the array similarly to pcolormesh. Seems doable. |
Yes I figure the machinery is obviously there already :) |
|
Bug report
Bug summary
matplotlib.pyplot.imshow
doesn't seem to play nicely withunyt_arrays
like other plotting functions do.Description
This problem was originally reported on unyt (yt-project/unyt#161)
According to unyt's documentation matplotlib is "unyt_aware", but it seems that some plotting functions are not well behaved.
What I Did
Code for reproduction
Actual outcome
Full trace
Expected outcome
A usable figure :)
Matplotlib version
print(matplotlib.get_backend())
): MacOSXmpl installed via cona (Conda-forge channel)
The text was updated successfully, but these errors were encountered: