使用matplotlib平滑imshow情节

Syl*_*ain 1 python matplotlib filter imshow

我正在用matplotlib.pyplot中的imshow绘制一个计数密度,但我希望有一个更平滑的情节.

在此输入图像描述

我可以对此应用任何过滤器吗?

M.T*_*M.T 7

尝试使用插值参数: ax.imshow(grid, interpolation=interp_method)

matplotlib演示

matplotlib api 产量

如果你手动想要处理过滤器的强度,你可以做一些事情(scipy.ndimage有很多过滤器)

from scipy.ndimage.filters import gaussian_filter
arr=np.zeros((20,20))
arr[0,:]=3
arr[0,0]=20
arr[19,19]=30
arr[10:12,10:12]=10

filtered_arr=gaussian_filter(arr, sigma)
plt.imshow(filtered_arr)
Run Code Online (Sandbox Code Playgroud)

得到(从左上角:原始图像,西格玛= 1,2,3): 在此输入图像描述