Description
Bug report
Bug summary
When using imshow with larger images, you lose pixel resolution for low intensity pixels with lots of nearby zeros (not sure if the intensity or nearby zeros are relevant, or just relative isolation of the pixel). It's like they're being interpolated away, even if interpolation is set to nearest. This is new behavior in version 2.1.
Code for reproduction
Use the attached npy file, which is an image referenced in this test script.
import matplotlib.pyplot as plt
import numpy as np
img = np.load('test_image.npy')
#Display full image
plt.imshow(img, interpolation = 'nearest')
plt.clim(0, 5)
plt.show()
#Display part of image
plt.imshow(img[200:400,500:700], interpolation = 'nearest')
plt.clim(0, 5)
plt.show()
Actual outcome
Using matplotlib 2.1.1:
Screenshot from the display of full image (first plot in code above):
Using the zoom tool to zoom in on a region when the full image is plotted:
Plotting roughly the same zoom region initially (second plot in code above):
Expected outcome
It should all look like the third image. Here's the output when the same code is run in version 2.0.2
Screenshot from the display of full image (first plot in code above):
Using the zoom tool to zoom in on a region when the full image is plotted:
Plotting roughly the same zoom region initially (second plot in code above):
Matplotlib version
- Operating system: macOS 10.12.6
- Matplotlib version: 2.1.1 (broken) and 2.0.2 (working)
- Matplotlib backend (
print(matplotlib.get_backend())
): MacOSX - Python version: 2.7.12
- Other libraries: numpy version 1.13.3
All libraries are installed through conda, using the standard channel. This includes both versions of matplotlib (2.1.1 and 2.0.2).
Numpy file with image data:
test_image.zip