8000 Backport PR #14397: Correctly set clip_path on pcolorfast return artist. · matplotlib/matplotlib@537a3d5 · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit 537a3d5

Browse files
efiringMeeseeksDev[bot]
authored andcommitted
Backport PR #14397: Correctly set clip_path on pcolorfast return artist.
1 parent 62fc0ca commit 537a3d5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6395,6 +6395,9 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
63956395
ret.set_clim(vmin, vmax)
63966396
else:
63976397
ret.autoscale_None()
6398+
if ret.get_clip_path() is None:
6399+
# image does not already have clipping set, clip to axes patch
6400+
ret.set_clip_path(self.patch)
63986401

63996402
ret.sticky_edges.x[:] = [xl, xr]
64006403
ret.sticky_edges.y[:] = [yb, yt]

lib/matplotlib/tests/test_bbox_tight.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,21 @@ def test_bbox_inches_tight_raster():
9090

9191

9292
def test_only_on_non_finite_bbox():
93-
9493
fig, ax = plt.subplots()
9594
ax.annotate("", xy=(0, float('nan')))
9695
ax.set_axis_off()
9796
# we only need to test that it does not error out on save
9897
fig.savefig(BytesIO(), bbox_inches='tight', format='png')
98+
99+
100+
def test_tight_pcolorfast():
101+
fig, ax = plt.subplots()
102+
ax.pcolorfast(np.arange(4).reshape((2, 2)))
103+
ax.set(ylim=(0, .1))
104+
buf = BytesIO()
105+
fig.savefig(buf, bbox_inches="tight")
106+
buf.seek(0)
107+
height, width, _ = plt.imread(buf).shape
108+
# Previously, the bbox would include the area of the image clipped out by
109+
# the axes, resulting in a very tall image given the y limits of (0, 0.1).
110+
assert width > height

0 commit comments

Comments
 (0)
0