The resulting figure is very small at the center of the grey window, while most of the space is unoccupied. How can I set the parameters to make the figure larger? I tried figsize=(xx,xx) and it’s not what I want. Thanks!
If you don’t give an aspect argument to imshow, it will use the value for image.aspect in your matplotlibrc. The default for this value in a new matplotlibrc is equal.
So imshow will plot your array with equal aspect ratio.
If you don’t need an equal aspect you can set aspect to auto
from matplotlib import pyplot as plt
import random
import numpy as np
random = np.random.random ([8,90])
plt.figure(figsize =(20,2))
plt.imshow(random, interpolation='nearest')
as requested by @baxxx, here is an update because random.rand is deprecated meanwhile.
This works with matplotlip 3.2.1:
from matplotlib import pyplot as plt
import random
import numpy as np
random = np.random.random ([8,90])
plt.figure(figsize = (20,2))
plt.imshow(random, interpolation='nearest')
This plots:
To change the random number, you can experiment with np.random.normal(0,1,(8,90)) (here mean = 0, standard deviation = 1).