-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
pcolorfast misbehaves when changing axis limits #13576
Comments
Quick fix: Set the clip path manually.
Of course this should be done internally though I wonder why if the clip_path isn't set, the image would still be clipped visually. |
I can't reproduce this on master using ipython with |
Yes this is specific to the inline backend, or more precisely to the |
Because for the better or (mostly) the worse this additional clipping is handled by _make_image. Looks like diff --git i/lib/matplotlib/image.py w/lib/matplotlib/image.py
index 656cc47b0..c95db0e46 100644
--- i/lib/matplotlib/image.py
+++ w/lib/matplotlib/image.py
@@ -855,8 +855,10 @@ class AxesImage(_ImageBase):
def get_window_extent(self, renderer=None):
x0, x1, y0, y1 = self._extent
- bbox = Bbox.from_extents([x0, y0, x1, y1])
- return bbox.transformed(self.axes.transData)
+ return Bbox.intersection(
+ Bbox.from_extents([x0, y0, x1, y1])
+ .transformed(self.axes.transData),
+ self.axes.bbox)
def make_image(self, renderer, magnification=1.0, unsampled=False):
# docstring inherited (edit: well, really, should be intersecting with clip_path, but see #14396). |
@anntzer will you be able to turn this into a PR in the next few days, so that it can get into the release that @tacaswell is planning? |
I would like to first figure out why this only affects pcolorfast and not imshow, even though both should be equally affected. Edit: OK, that's because imshow() does set the clip_path, which is not actually used for drawing (#14396 -- explaing why pcolorfast can get away with not setting it...) but is used for tightbboxing... |
Bug report
With a figure that contains a
pcolorfast
plot, when I limit the range of an axis (usingaxis
,xlim
orylim
), I get a significant amount of empty space in the figure. This makes manual zooming into a plot impractical (increased zoom creates more empty space and makes the resulting plot smaller).Code for reproduction
Actual outcome
Note the large amount of empty space above the figure. This is proportional to the amount of the zoom, i.e., had we drawn the whole plot without limiting the axis it would take that much space, but the aspect ratio is now different so that it's 1:1 based on the specified limits. In this case asking to zoom at 1/4 of the y axis, results in a figure that's 4 times taller. Had I zoomed into the x axis, the empty space would be on the right. Zooming on both axes will add empty space on top and right.
Expected outcome
A figure that did not have as much empty space on top (I did this one with
pcolormesh
instead).Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineThe text was updated successfully, but these errors were encountered: