Skip to content

Commit dbc529b

Browse files
committed
Merge pull request matplotlib#3978 from mdboom/fix-image-clip-zoom
Fix clipping/zooming of inverted images
2 parents cdb6771 + 3418c09 commit dbc529b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/matplotlib/image.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,7 @@ def _get_unsampled_image(self, A, image_extents, viewlim):
186186
iy0 = max(0, int(y0 - self._filterrad))
187187
y1 = (viewlim.y1-ymin)/dyintv * numrows
188188
iy1 = min(numrows, int(y1 + self._filterrad))
189-
if self.origin == 'upper':
190-
yslice = slice(numrows-iy1, numrows-iy0)
191-
else:
192-
yslice = slice(iy0, iy1)
189+
yslice = slice(iy0, iy1)
193190
ymin_old = ymin
194191
ymin = ymin_old + iy0*dyintv/numrows
195192
ymax = ymin_old + iy1*dyintv/numrows
Loading

lib/matplotlib/tests/test_image.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,20 @@ def test_get_window_extent_for_AxisImage():
357357
assert_array_equal(im_bbox.get_points(), [[400, 200], [700, 900]])
358358

359359

360+
@image_comparison(baseline_images=['zoom_and_clip_upper_origin'],
361+
remove_text=True,
362+
extensions=['png'])
363+
def test_zoom_and_clip_upper_origin():
364+
image = np.arange(100)
365+
image = image.reshape((10, 10))
366+
367+
fig = plt.figure()
368+
ax = fig.add_subplot(111)
369+
ax.imshow(image)
370+
ax.set_ylim(2.0, -0.5)
371+
ax.set_xlim(-0.5, 2.0)
372+
373+
360374
if __name__=='__main__':
361375
import nose
362376
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 commit comments

Comments
 (0)