matplotlib - segmentation fault (core dumped) while trying to plot a grid
I'm trying to plot a grid but exists with the error message -
(feature_vis.py:27730): Gdk-WARNING **: 03:23:47.745: Native Windows wider or taller than 32767 pixels are not supported
Segmentation fault (core dumped)

model_weights = './Mutual-Channel-Loss-master/model_info_best.pth'
model_features = './Mutual-Channel-Loss-master/features_best_new.pth'
weights = torch.load(model_weights, map_location = torch.device('cpu'))
features = torch.load(model_features, map_location = torch.device('cpu'))
activations = features['features']
feature_map = activations[0][0][3]
# feature_maps = np.load(path, allow_pickle = True)
# test = feature_maps[0][0][0]
fig = plt.figure(figsize = (300, 500))
grid = ImageGrid(fig, 111,  # similar to subplot(111)
                 nrows_ncols=(20, 30),  # creates 2x2 grid of axes
                 axes_pad=0.1,  # pad between axes in inch.
                 )
for ax, im in zip(grid, feature_map):
    # Iterating over the grid returns the Axes.
    im = im.to('cpu').numpy()
    ax.imshow(im, cmap = 'gray')

plt.savefig('test.png', ppi = 300)

How should I fix / Debug this?
I am using python 3.6.9 and on ubuntu 18.04

The unit used by the attribute figsize is the inch. So an image of size 300x500 with dpi=300 is insanely huge (45M pixels) and mpl cannot handle that. If you want a 300 by 500 (pixels) image you have to first convert it to inches. In this case it would be something like ~1x1.7.
