matplotlib imshow() 的默认行为

Default behavior of matplotlib imshow()

在 matplotlib 中,当使用 imshow() 时,默认行为是使用双线性插值显示图像。

我知道我可以通过调用 imshow(...,interpolation='none') 明确地更改它。但这对于多次调用 imshow 来说很麻烦。

如何更改默认行为,例如 interpolation='none'

找到了! 显然,有一本字典控制着 matplotlib 的许多方面,叫做 rcParams。直接来自 the matplotlib docs:

import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.color'] = 'r'

在我的例子中,我必须设置:

rcParams['image.interpolation']='none'