Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc1bf99

Browse files
authored
Merge pull request#14774 from anntzer/image-clip
Fix image bbox clip.
2 parentsbcdcb93 +ae5c6ad commitdc1bf99

File tree

4 files changed

+58
-39
lines changed

4 files changed

+58
-39
lines changed

‎lib/matplotlib/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,9 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
863863
bbox=Bbox(np.array([[x1,y1], [x2,y2]]))
864864
transformed_bbox=TransformedBbox(bbox,trans)
865865
returnself._make_image(
866-
self._A,bbox,transformed_bbox,self.axes.bbox,magnification,
867-
unsampled=unsampled)
866+
self._A,bbox,transformed_bbox,
867+
self.get_clip_box()orself.axes.bbox,
868+
magnification,unsampled=unsampled)
868869

869870
def_check_unsampled_image(self,renderer):
870871
"""

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

Lines changed: 37 additions & 37 deletions
Loading

‎lib/matplotlib/tests/test_image.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,3 +1083,21 @@ def test_deprecation():
10831083
withpytest.warns(MatplotlibDeprecationWarning):
10841084
# Enough arguments to pass "shape" positionally.
10851085
obj.imshow(data,*[None]*10)
1086+
1087+
1088+
deftest_respects_bbox():
1089+
fig,axs=plt.subplots(2)
1090+
foraxinaxs:
1091+
ax.set_axis_off()
1092+
im=axs[1].imshow([[0,1], [2,3]],aspect="auto",extent=(0,1,0,1))
1093+
im.set_clip_path(None)
1094+
# Make the image invisible in axs[1], but visible in axs[0] if we pan
1095+
# axs[1] up.
1096+
im.set_clip_box(axs[0].bbox)
1097+
buf_before=io.BytesIO()
1098+
fig.savefig(buf_before,format="rgba")
1099+
assert {*buf_before.getvalue()}== {0xff}# All white.
1100+
axs[1].set(ylim=(-1,0))
1101+
buf_after=io.BytesIO()
1102+
fig.savefig(buf_after,format="rgba")
1103+
assertbuf_before.getvalue()!=buf_after.getvalue()# Not all white.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp