Matplotlib:绘制没有模糊的像素

时间:2013-11-24 14:08:00

标签: python matplotlib plot

我需要绘制一个带有greycsale值的2x2数组。如果我使用命令

plt.imshow(matrix_1, cmap = cm.Greys_r)
plt.show()

我得到了下面的图像,其中各种像素没有明确分开。你知道怎么解决这个问题吗?

enter image description here

1 个答案:

答案 0 :(得分:3)

指定interpolation='none'

plt.imshow(matrix_1, cmap = cm.Greys_r, interpolation='none')
  

插值:字符串,可选,默认值:无

     

可接受的值是'none','nearest','bilinear','bicubic',   'spline16','spline36','hanning','hamming','hermite','kaiser',   'quadric','catrom','gaussian','bessel','mitchell','sinc',   “的Lanczos”

     

如果插值为None,则默认为rc image.interpolation。也可以看看   filternorm和filterrad参数。如果插值是'none',   然后不对Agg,ps和pdf后端执行插值。   其他后端将回归到“最近”。

http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow