这是我的HeatMap绘图函数:
def plot_heatmap(alphas, k_list, title_prefix="", years=["Y2013", "Y2014"]):
data = [
Heatmap(
name="",
z= alphas,
x=years,
y=k_list,
hoverongaps = False,
zauto=False,
zmin=zmin,
zmax=zmax,
colorscale= color_custom,
colorbar = dict(
title="Alpha Value",
thicknessmode="pixels",
thickness=50,
yanchor="top",
y=1,
len=480,
lenmode="pixels",
ticks="outside",
dtick=zmax / 10
)
)
]
fig = Figure(
data=data,
layout=Layout(
width = 640,
height = round(60 * len(k_list)) if round(60 * len(k_list)) > 640 else 640,
# autosize = True,
title=title_prefix + " | HeatMap : alphas",
)
)
fig.data[0]['hoverinfo'] = 'all'
fig['layout']['yaxis']['scaleanchor']='x'
iplot(fig)
现在我的解决方法是height = round(60 * len(k_list)) if round(60 * len(k_list)) > 640 else 640,
对象中的*Layout
。
结果是这样的:(我不想看到绘图上的灰色部分,我该怎么办]]
[我认为这里发生的是由于某种原因,故意将您的years
输入数字化,您可以通过添加使该变量明确地归类
fig['layout']['xaxis']['type'] = 'category'