Answers:
如果你不给一个aspect参数imshow,它会使用值image.aspect在你的matplotlibrc。在一个新的该值的默认值matplotlibrc是equal。因此,imshow将以相等的纵横比绘制数组。
如果您不需要平等的方面,可以将其设置aspect为auto
imshow(random.rand(8, 90), interpolation='nearest', aspect='auto')
如下图

如果您想要相等的长宽比,则必须figsize根据长宽比进行调整
fig, ax = subplots(figsize=(18, 2))
ax.imshow(random.rand(8, 90), interpolation='nearest')
tight_layout()
这给你:

奇怪,它绝对对我有用:
from matplotlib import pyplot as plt
plt.figure(figsize = (20,2))
plt.imshow(random.rand(8, 90), interpolation='nearest')
我正在使用“ MacOSX”后端,顺便说一句。
plt.figure(figsize = (x_new, y_new)),对于imgshow(),必须立即导入ioimage,因为SciPy imageshow()即将被弃用
random.rand同时已弃用。这适用于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')
此图:
要更改随机数,您可以进行实验np.random.normal(0,1,(8,90))(此处的均值= 0,标准差= 1)。