Closed marscher closed 6 months ago
The figsize argument has no effect on the output. Please note that you can manually resize the canvas using the gray triangle located in the lower-left corner. After resizing, the image will be aligned to the top.
Centring the image is standard Matplotlib behaviour. If you want the image at the top of its axes you can set the anchor to 'N' for north:
plt.gca().set_anchor('N')
Thanks, centering helps a bit in the sense that the viable information is aligned on top. But the the canvas is still far too large for actual figure. Now the free space is just all in the south :)
There may be some confusion about terms here:
imshow
uses a fixed aspect ratio to keep pixels square.If you want to keep the figure this size but stretch the image so it fits better, try aspect="auto"
in the call to imshow
. If you want the image the same shape but want the figure to fit around it, choose a different figsize.
Right, I made a mistake when setting the figsize in my mimimum reproducing example. Actually I compute the figsize using data shape and the current DPI. This leads to the desired output. Thanks for your support.
Describe the issue
When plotting an image using pylab.imshow(), the top and bottom padding are very large. I'm using the Agg backend with ipympls frontend. I expected the image to be shown at the top. It seems centered in the output div.
The code to generate the plot is this snippet:
Versions