0
我有一個從一個數據框產生的熱圖。不幸的是,它沒有一個顏色條。我嘗試添加一個,但它不顯示。有任何想法嗎?Plotly熱圖 - Python - 添加顏色條
這是代碼:
zp = df_hml.values.tolist()
zp.reverse()
z = zp
z_text = np.around(z)
x = [threeYr,twoYr,oneYr,Yr]
y=['March', 'February', 'January', 'December', 'November', 'October', 'September', 'August', 'July', 'June', 'May', 'April']
layout = go.Layout(
autosize=False,
width=700,
height=450,
margin=go.Margin(
l=150,
r=160,
b=50,
t=100,
pad=3
),
)
colorscale = [[0, '#454D59'],[0.5, '#FFFFFF'], [1, '#F1C40F']]
fig = ff.create_annotated_heatmap(z, x=x, y=y, annotation_text=z_text,colorscale=colorscale, hoverinfo='z')
# Make text size smaller
for i in range(len(fig.layout.annotations)):
fig.layout.annotations[i].font.size = 9
fig.layout.title = '<b>Research - HEATMAP</b><br>Applications'
fig.layout.titlefont.size = 14
fig.layout.width = 700
fig.layout.height = 550
plotly.offline.iplot(fig, config={"displayModeBar": False}, show_link=False, filename='annotated_heatmap_numpy')
將會產生這樣的:
即使它是使用我使用的三種顏色創建單獨的顏色條將會有所幫助 – ScoutEU