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

Fix image bbox clip.#14774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dstansby merged 1 commit intomatplotlib:masterfromanntzer:image-clip
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -863,8 +863,9 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
bbox = Bbox(np.array([[x1, y1], [x2, y2]]))
transformed_bbox = TransformedBbox(bbox, trans)
return self._make_image(
self._A, bbox, transformed_bbox, self.axes.bbox, magnification,
unsampled=unsampled)
self._A, bbox, transformed_bbox,
self.get_clip_box() or self.axes.bbox,
magnification, unsampled=unsampled)

def _check_unsampled_image(self, renderer):
"""
Expand Down
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletionslib/matplotlib/tests/test_image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1083,3 +1083,21 @@ def test_deprecation():
with pytest.warns(MatplotlibDeprecationWarning):
# Enough arguments to pass "shape" positionally.
obj.imshow(data, *[None] * 10)


def test_respects_bbox():
fig, axs = plt.subplots(2)
for ax in axs:
ax.set_axis_off()
im = axs[1].imshow([[0, 1], [2, 3]], aspect="auto", extent=(0, 1, 0, 1))
im.set_clip_path(None)
# Make the image invisible in axs[1], but visible in axs[0] if we pan
# axs[1] up.
im.set_clip_box(axs[0].bbox)
buf_before = io.BytesIO()
fig.savefig(buf_before, format="rgba")
assert {*buf_before.getvalue()} == {0xff} # All white.
axs[1].set(ylim=(-1, 0))
buf_after = io.BytesIO()
fig.savefig(buf_after, format="rgba")
assert buf_before.getvalue() != buf_after.getvalue() # Not all white.

[8]ページ先頭

©2009-2025 Movatter.jp