Description
Bug report
With a figure that contains a pcolorfast
plot, when I limit the range of an axis (using axis
, xlim
or ylim
), 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
%matplotlib inline
from matplotlib.pyplot import figure, gca, axis
from numpy import array
# Give the figure a background color to see the empty space on a white page
figure( facecolor='r')
# Make a pclorfast plot and zoom into the y axis
gca().pcolorfast( array( [[1,2],[3,4]]))
axis( [0,2,0,.5])
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
- Operating system: MacOS 10.14.3, and Ubuntu 16
- Matplotlib version: 3.0.2
- Matplotlib backend (
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inline - Python version: 3.6.8
- Jupyter version (if applicable): JupyterLab 0.35.3, also in nteract 0.12.3
- Other libraries: