数字 imshow// 太麻木了

我正在尝试想象一个数组 numpy, 使用 imshow//, 看起来像 imagesc// 在 Matlab.


imshow/random.rand/8, 90/, interpolation='nearest'/


结果图在灰色窗口的中心非常小,而大多数空间不忙。 如何设置参数以使图形更新? 我试过了 figsize=/xx,xx/, 这不是我想要的。 谢!
已邀请:

小明明

赞同来自:

如果你没有争吵
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//


是什么给你:

帅驴

赞同来自:

这很奇怪,它绝对适合我:


figure/figsize = /20,2//
imshow/random.rand/8, 90/, interpolation='nearest'/


顺便说一下,我使用后端 "MacOSX".

卫东

赞同来自:

我也是新的 python. 这是它看起来的样子,会做你想要的


axes/[0.08, 0.08, 0.94-0.08, 0.94-0.08]/ #[left, bottom, width, height]
axis/'scaled'/`


我相信它解决了画布的大小。

江南孤鹜

赞同来自:

更新 2020

按要求 @baxxx, 这是一个续约,因为
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'/


这一领谋:

https://i.stack.imgur.com/1Rhca.png
要更改随机数,可以尝试
np.random.normal/0,1,/8,90//

/这是平均值 = 0, 标准偏差 = 1/.

要回复问题请先登录注册