8000 Correctly set clip_path on pcolorfast return artist. by anntzer · Pull Request #14397 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Correctly set clip_path on pcolorfast return artist. #14397

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6309,6 +6309,9 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
ret.set_clim(vmin, vmax)
elif np.ndim(C) == 2: # C.ndim == 3 is RGB(A) so doesn't need scaling.
ret.autoscale_None()
if ret.get_clip_path() is None:
# image does not already have clipping set, clip to axes patch
ret.set_clip_path(self.patch)

ret.sticky_edges.x[:] = [xl, xr]
ret.sticky_edges.y[:] = [yb, yt]
Expand Down
14 changes: 13 additions & 1 deletion lib/matplotlib/tests/test_bbox_tight.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,21 @@ def test_bbox_inches_tight_raster():


def test_only_on_non_finite_bbox():

fig, ax = plt.subplots()
ax.annotate("", xy=(0, float('nan')))
ax.set_axis_off()
# we only need to test that it does not error out on save
fig.savefig(BytesIO(), bbox_inches='tight', format='png')


def test_tight_pcolorfast():
fig, ax = plt.subplots()
ax.pcolorfast(np.arange(4).reshape((2, 2)))
ax.set(ylim=(0, .1))
buf = BytesIO()
fig.savefig(buf, bbox_inches="tight")
buf.seek(0)
height, width, _ = plt.imread(buf).shape
# Previously, the bbox would include the area of the image clipped out by
# the axes, resulting in a very tall image given the y limits of (0, 0.1).
assert width > height
0