如何在散景中制作相关热图?
import pandas as pd
import bokeh.charts
df = pd.util.testing.makeTimeDataFrame(1000)
c = df.corr()
p = bokeh.charts.HeatMap(c) # not right
# try to make it a long form
# (and it's ugly in pandas to use 'index' in melt)
c['x'] = c.index
c = pd.melt(c, 'x', ['A','B','C','D'])
# this shows the right 4x4 matrix, but values are still wrong
p = bokeh.charts.HeatMap(c, x = 'x', y = 'variable', values = 'value')
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我可以在侧面制作一个颜色条,而不是情节中的图例吗?以及如何选择颜色范围/映射,例如深蓝色(-1)到白色(0)到深红色(+1)?