1

Im trying to make a line graph of a pandas df with plotly and i want to show the corresponding value of that point in another df in the hovering annotation of the graph.

import pandas as pd
import numpy as np
pd.options.plotting.backend = "plotly"
import plotly.express as px
vals=[[1,2,3],
   [4,5,6],
   [7,8,9]]
df = pd.DataFrame(np.random.rand(3,3))
df2 = pd.DataFrame(vals)


fig = df.plot(title="Pandas Backend Example", template="simple_white",
              labels=dict(index="time", value="money", variable="option"),hover_data = df2.values)
fig.show()

I tried to achieve this by using hover_data = df2.values but instead of showing me only one value it showed me the whole column.

ie: when i hover on the first point of the first line on the graph i want the hover to show me the 0,0th value of the df. But this solution shows me the whole 0th column.

is there a way to make it so that it shows only the corresponding value? Thanks from now

mag1103
  • 11
  • 3

0 Answers0