本文介绍了平滑地绘制热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用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'
,'best'
或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:
这篇关于平滑地绘制热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!