plotly heatmap hovertemplate vs hover text
import plotly
import random
plotly.offline.init_notebook_mode()
colorscale = [[0, '#454D59'],[0.5, '#FFFFFF'], [1, '#F1C40F']]
x = [2015, 2016, 2017]
y = ['March', 'February', 'January', 'December', 'November', 'October', 'September', 'August', 'July', 'June', 'May', 'April']
z = [[i + random.random() for i in range(len(x))] for ii in range(len(y))]
hovertext = list()
for yi, yy in enumerate(y):
hovertext.append(list())
for xi, xx in enumerate(x):
hovertext[-1].append('FY: {}<br />Month: {}<br />Count: {}'.format(xx, yy, z[yi][xi]))
data = [plotly.graph_objs.Heatmap(z=z,
colorscale=colorscale,
x=x,
y=y,
hoverinfo='text',
text=hovertext)]
layout = plotly.graph_objs.Layout(autosize=False,
font=dict(family="Courier New"),
width=700,
height=450,
margin=plotly.graph_objs.Margin(l=150,
r=160,
b=50,
t=100,
pad=3)
)
fig = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.iplot(fig,filename='pandas-heatmap')
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line