This question already has an answer here:
I am plotting a density of counts with imshow from matplotlib.pyplot but I'd like to have a smoother plot.
Can I apply any filter on this?
Try using the interpolation argument:
ax.imshow(grid, interpolation=interp_method)
If you manually want to handle how strong the filter is you could do something along the lines of (scipy.ndimage has a lot of filters)
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)
来源:https://stackoverflow.com/questions/34230108/smoothing-imshow-plot-with-matplotlib