If you look at the documentation of plotly.figure_factory.create_annotated_heatmap
, you will not find any attribute to change the hover data. Thus, I suggest using plotly.graph_objects
as follows:
Code
import numpy as np
import plotly.graph_objects as go
z = np.round(np.random.rand(5,5),2)
p = np.round(np.random.rand(5,5),2)
feature_1 = ['Buttinia1 type',
'Buttinia2 type',
'Buttinia3 type',
'Buttinia4 type',
'Buttinia5 type']
feature_2 = ['Diporopollis aff. assamica',
'Esporas, hifas y/o cuerpos fructiferos',
'Forro de foraminífero',
'Sphaeromorpho',
'Scolecodonte']
hovertext = np.empty(z.shape, dtype=object)
for i, ftr2 in enumerate(feature_2):
for j,ftr1 in enumerate(feature_1):
hovertext[i,j] = f'feature 1: {ftr1}<br />feature 2: {ftr2}<br />Correlation: {z[i,j]}<br />p-value: {p[i,j]}'
fig= go.Figure(go.Heatmap(z=z,
x=feature_1,
y=feature_2,
hoverinfo='text',
hovertext=hovertext,
texttemplate="%{z}"))
fig.show()
Output
You can define features 1 nd 2 by using df.feature1.unique().tolist()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.