-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
document that imshow now respects scale #7661
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
To be clear, you were relying on a bug / undefined behavior. The new behavior is in arguably correct. I think you want to be using http://matplotlib.org/examples/pylab_examples/image_nonuniform.html in 2.0+ but not sure if that will work as expected in <2.0. I think |
Agree with @tacaswell about pcolor. This works in 1.5 and the 2.0 RC: |
Don't use pcolor--it's slow, and has no advantages in most cases. Use pcolormesh. Supply the cell boundaries explicitly: import numpy as np
import matplotlib.pyplot as plt
tmp = np.arange(30).reshape(5, 6)
x = np.linspace(0, 6, 7)
y = 10**np.linspace(0, 5, 6)
X, Y = np.meshgrid(x, y)
fig, ax = plt.subplots()
ax.set_yscale('log')
ax.pcolormesh(x, y, tmp)
ax.autoscale('tight')
plt.show() It should be possible to do this more efficiently with Axes.pcolorfast, but it doesn't work with a log scale. That's a bug. |
DOC: explain non-linear scales and imshow (closes #7661)
DOC: explain non-linear scales and imshow (closes #7661)
Thanks a lot for your help. I finally had the time to implement the |
What about when loading an RGB image from file? |
Uh oh!
There was an error while loading. Please reload this page.
With the introduction of matplotlib 2.0.0 using
plt.imshow()
together withplt.yscale('log')
changed its behavior.The following example code:
produces with python 3.4.3 and matplotlib 1.5.1

and the following warning:
../.local/lib/python3.4/site-packages/matplotlib/image.py:375: UserWarning: Images are not supported on non-linear axes. warnings.warn("Images are not supported on non-linear axes.")
With python 3.4.3 and matplotlib 2.0.0rc1 it produces

Thus, 2.0.0 assumes that underneath the linear bin id of the numpy array
tmp
lies a linear data extend (y-axis) scaling.If however my logarithmic extent is mapped correctly onto the linear bin id of the numpy array - the old behavior is exactly what represents the data.
Is it possible to reproduce the old behavior without relabeling the y-axis by hand?
Is there an option, the tell imshow directly that a specify data axis is already log-scaled?
and if so:
Is it possible to have the same behavior independent of the matplotlib version used?
System:
Ubuntu 14.04.5 - Linux-Kernel 4.4.0-38
Matplotlib and Python are available via the HPC module system (probably via pip)
cc'ing: @s0vereign
The text was updated successfully, but these errors were encountered: