8000 Merge pull request #2734 from cimarronm/im_setclipbox_fix · matplotlib/matplotlib@129c738 · GitHub
[go: up one dir, main page]

Skip to content

Commit 129c738

Browse files
committed
Merge pull request #2734 from cimarronm/im_setclipbox_fix
Fixed issue #1733 - AxesImage draw function now takes into account the
2 parents 7759dc6 + e4da848 commit 129c738

File tree

5 files changed

+460
-3
lines changed

5 files changed

+460
-3
lines changed

lib/matplotlib/image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ def draw(self, renderer, *args, **kwargs):
354354

355355
l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
356356
gc = renderer.new_gc()
357-
gc.set_clip_rectangle(self.axes.bbox.frozen())
358-
gc.set_clip_path(self.get_clip_path())
357+
self._set_gc_clip(gc)
359358
gc.set_alpha(self.get_alpha())
360359

361360
if self._check_unsampled_image(renderer):
Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg

Lines changed: 445 additions & 0 deletions
Loading

lib/matplotlib/tests/test_image.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ def test_image_clip():
167167

168168
im = ax.imshow(d, extent=(-pi,pi,-pi/2,pi/2))
169169

170+
@image_comparison(baseline_images=['image_cliprect'])
171+
def test_image_cliprect():
172+
import matplotlib.patches as patches
173+
174+
fig = plt.figure()
175+
ax = fig.add_subplot(111)
176+
d = [[1,2],[3,4]]
177+
178+
im = ax.imshow(d, extent=(0,5,0,5))
179+
180+
rect = patches.Rectangle(xy=(1,1), width=2, height=2, transform=im.axes.transData)
181+
im.set_clip_path(rect)
182+
170183
@image_comparison(baseline_images=['imshow'], remove_text=True)
171184
def test_imshow():
172185
import numpy as np
@@ -290,7 +303,7 @@ def test_rasterize_dpi():
290303

291304
axes[2].plot([0,1],[0,1], linewidth=20.)
292305
axes[2].set(xlim = (0,1), ylim = (-1, 2))
293-
306+
294307
# Low-dpi PDF rasterization errors prevent proper image comparison tests.
295308
# Hide detailed structures like the axes spines.
296309
for ax in axes:

0 commit comments

Comments
 (0)
0