Is there a way to change the figsize of a matplotlib figure after drawing an image with ax.imshow()?
I have a numpy array of size (10, 100) (let's say) and I want to plot it with ax.imshow(). It should look like the code below, more or less:
some_image = np.random.rand(10, 100)
fig = plt.figure()
ax = fig.gca()
ax.imshow(some_image)
and I get this:
My output with lots of blank space above and below.
What I'd like to do is to change the figsize of my fig object accordingly to my ax.imshow output, so that I have less blank space above and below but I need to keep imshow(aspect='equal') as I am plotting an image.
I am not asking to remove the blank space entirely (as I found in some questions), because I need the axes and the labels, only to reduce its size.
I already read different answers on here, but everyone was only answering to set aspect='auto' in imshow, to fit the image to the figsize. I need to do the other way around.
I also tried plt.tight_layout as suggested in another answer (I'll update the link if I find it again) but with no success.