0

When creating subplots with matplotlib i cannot get tight layout where there would not be any spaces between subplot items.

import numpy as np
import matplotlib.pyplot as plt

fig, axes = plt.subplots(3, 3, figsize=(10,10),gridspec_kw = {'wspace':0, 'hspace':0})

for i, ax in enumerate(axes.ravel()):
    im = ax.imshow(np.random.normal(size=200).reshape([10,20]))
    ax.axis('off')

plt.tight_layout()

Subplots would consist of images. Seems like there is way to do this when you are not using images. So i assume, there is some configuration about imshow(). I would like to keep aspect ratio of images, but make subplots compact as possible. this is what i get now, but as you can see, there is a lot of row padding https://i.stack.imgur.com/Egkdy.jpg

qwerry
  • 215
  • 1
  • 8

0 Answers0