2024-06-16 11:42:03 发布
网友
我正试图使用imshow()可视化numpy数组,因为它与Matlab中的imagesc()类似。
imshow(random.rand(8, 90), interpolation='nearest')
在灰色窗口的中心,生成的图形非常小,而大部分空间是空的。如何设置参数使图形变大?我试过figsize=(xx,xx),但这不是我想要的。谢谢!
如果不给imshow一个aspect参数,它将使用matplotlibrc中image.aspect的值。新matplotlibrc中此值的默认值是equal。 因此imshow将以相等的纵横比绘制数组。
imshow
aspect
matplotlibrc
image.aspect
equal
如果不需要相等的方面,可以将aspect设置为auto
auto
imshow(random.rand(8, 90), interpolation='nearest', aspect='auto')
下图所示
如果你想要一个相等的纵横比,你必须根据纵横比调整你的figsize
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”后端
我也是python新手。这是一个你想做什么就做什么的东西
axes([0.08, 0.08, 0.94-0.08, 0.94-0.08]) #[left, bottom, width, height] axis('scaled')`
我相信这决定了画布的大小。
如果不给
imshow
一个aspect
参数,它将使用matplotlibrc
中image.aspect
的值。新matplotlibrc
中此值的默认值是equal
。 因此imshow
将以相等的纵横比绘制数组。如果不需要相等的方面,可以将
aspect
设置为auto
下图所示
如果你想要一个相等的纵横比,你必须根据纵横比调整你的
figsize
它给你:
很奇怪,这对我来说绝对有效:
顺便说一下,我正在使用“MacOSX”后端
我也是python新手。这是一个你想做什么就做什么的东西
我相信这决定了画布的大小。
相关问题 更多 >
编程相关推荐