I'm trying to use plotly.express
in python to generate a heatmap from a pandas dataframe with a custom hover template that includes additional variables. So for example:
import pandas as pd
import plotly.express as px
df = pd.DataFrame({'A': [10, 11, 12], 'B': [10, 12, 14], 'C': [12, 14, 16]},
index=['joe', 'tom', 'bob'])
fig = px.imshow(df)
fig.update_layout(xaxis={'title': 'Letters'}, yaxis={'title': 'Nicknames'})
fig.show()
Gives me this:
What I want is to add or replace a variable in the hover information, for instance, replace the nicknames with Joseph, Thomas and Robert.
This has to be possible, but I can't figure out how to do it with a heatmap. Is there a straight forward way to do this in plotly.express
? Should I use the "go" interface instead (if so, how)?