Skip to content

Commit

Permalink
Merge pull request #2734 from cimarronm/im_setclipbox_fix
Browse files Browse the repository at this point in the history
Fixed issue #1733 - AxesImage draw function now takes into account the
  • Loading branch information
tacaswell committed Jan 23, 2014
2 parents 7759dc6 + e4da848 commit 129c738
Show file tree
Hide file tree
Showing 5 changed files with 460 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/matplotlib/image.py
Expand Up @@ -354,8 +354,7 @@ def draw(self, renderer, *args, **kwargs):

l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
gc = renderer.new_gc()
gc.set_clip_rectangle(self.axes.bbox.frozen())
gc.set_clip_path(self.get_clip_path())
self._set_gc_clip(gc)
gc.set_alpha(self.get_alpha())

if self._check_unsampled_image(renderer):
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
445 changes: 445 additions & 0 deletions lib/matplotlib/tests/baseline_images/test_image/image_cliprect.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion lib/matplotlib/tests/test_image.py
Expand Up @@ -167,6 +167,19 @@ def test_image_clip():

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

@image_comparison(baseline_images=['image_cliprect'])
def test_image_cliprect():
import matplotlib.patches as patches

fig = plt.figure()
ax = fig.add_subplot(111)
d = [[1,2],[3,4]]

im = ax.imshow(d, extent=(0,5,0,5))

rect = patches.Rectangle(xy=(1,1), width=2, height=2, transform=im.axes.transData)
im.set_clip_path(rect)

@image_comparison(baseline_images=['imshow'], remove_text=True)
def test_imshow():
import numpy as np
Expand Down Expand Up @@ -290,7 +303,7 @@ def test_rasterize_dpi():

axes[2].plot([0,1],[0,1], linewidth=20.)
axes[2].set(xlim = (0,1), ylim = (-1, 2))

# Low-dpi PDF rasterization errors prevent proper image comparison tests.
# Hide detailed structures like the axes spines.
for ax in axes:
Expand Down

0 comments on commit 129c738

Please sign in to comment.