图imshow的()太小

问题描述:

我试图使用可视化imshow(),因为它类似于于imagesc()在Matlab一个numpy的阵列。图imshow的()太小

imshow(random.rand(8, 90), interpolation='nearest') 

由此产生的图形在灰色窗口的中心非常小,而大部分空间未被占用。我如何设置参数来使图形更大?我试图figsize =(XX,XX),这不是我想要的。谢谢!

如果您没有给imshow发送aspect参数,它将使用您的matplotlibrc中的image.aspect的值。在新matplotlibrc此值默认为equal。 所以imshow将绘制具有相同的纵横比你的阵列。

如果你并不需要一个平等方面可以设置aspectauto

imshow(random.rand(8, 90), interpolation='nearest', aspect='auto') 

这给下图

imshow-auto

如果你想你有一个平等的长宽比适应依据方面

fig, ax = subplots(figsize=(18, 2)) 
ax.imshow(random.rand(8, 90), interpolation='nearest') 
tight_layout() 

它给你:

imshow-equal

真奇怪,它肯定为我工作:

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

我现在用的是 “MacOSX的” 后台,顺便说一句。

我是新来的蟒蛇太大。这是看起来像会做你想要的东西

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

我相信这决定了画布的大小。