在情节中平滑热图 [英] Smoothen heatmap in plotly
本文介绍了在情节中平滑热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 plotly 创建概率密度矩阵的热图.
I wanted to create a heatmap of a probability density matrix using plotly.
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot
import plotly.graph_objs as go
probability_matrix = np.loadtxt("/path/to/file")
trace = go.Heatmap(z = probability_matrix)
data=[trace]
plot(data, filename='basic-heatmap')
这给了我这样的图像:
我想平滑正方形的颜色,以便图像中相邻正方形之间的过渡有点平滑".我想知道是否有一种方法可以做到这一点,而无需使用插值手动调整矩阵的大小.
I want to smoothen the color of the squares so that the transition between adjacent squares in the image are somewhat "smoother". I was wondering if there is a way of doing that, without manually resizing the matrix using interpolation.
推荐答案
你可以使用 zsmooth
参数,它可以取三个值('fast'
, '最佳'
,或False
).例如:
You can use the zsmooth
argument which can take three values ('fast'
, 'best'
, or False
). For example:
data = [go.Heatmap(z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
zsmooth = 'best')]
iplot(data)
会给你以下平滑的热图:
Will give you the following smooth heatmap:
这篇关于在情节中平滑热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文