python - 使用 matplotlib 平滑 imshow 图

标签 python matplotlib filter imshow

<分区>

我正在使用 matplotlib.pyplot 中的 imshow 绘制计数密度,但我想要一个更平滑的绘图。

enter image description here

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

最佳答案

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

matplotlib demo

matplotlib api output

如果您想手动处理过滤器的强度,您可以 做一些事情(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)

获取(从左上角开始:原始图像,sigma=1,2,3): enter image description here

关于python - 使用 matplotlib 平滑 imshow 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34230108/

相关文章:

internet-explorer-8 - IE 8 绝对定位元素在其父裁剪问题之外

php - 过滤 HTML 标签

python - 如何在Python中使用pandas根据两个参数对记录进行分组

python - 我在通过 SendGrid 发送电子邮件时在标题中添加了“回复”和“引用”,但它不起作用

python - 使用 hue 参数在 seaborn 中拆分 fiddle 图

python - 了解 gi.repository

python - 如何在python中创建一个简单的代理?

Python 正则表达式与 ","或字符串结尾不匹配

python - Opencv 转换为灰度无法正常工作

python - 将多个过滤器应用于元组列表