question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hover_data in PX doesn't accept df.index

See original GitHub issue

In wide-mode I can’t do this:

import plotly.express as px
df = px.data.stocks(indexed=True)
fig = px.line(df, hover_data={df.index: "|%B %d, %Y"} )

or find any other way of referring to the index.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
emmanuellecommented, Sep 10, 2020

The syntax is

import plotly.express as px
df = px.data.stocks()
fig = px.line(df, x=df.date, y=df.columns[1:], hover_data={'index': ("|%B %d, %Y", df.index)} )
fig.show()

Is this what you were asking? The keys of the hover_data dict need to be str or numbers.

0reactions
imadcatcommented, Nov 1, 2022

Or more generally: hover_data={df.index.name: ("|%Y", df.index)} … pretty obscure tho! Not sure where to document that one.

this works for single index, what about multiple index?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add elements to hover_data using plotly.express ...
It seems there is an issue with splitting on multiple values for hover_data / custom_data and all values are present at 0 index...
Read more >
Plotly express arguments in Python
import plotly.express as px df = px.data.iris() # Use directly Columns as argument. ... In the example below the index is displayed in...
Read more >
Visualization with Plotly.Express: Comprehensive guide
A detailed guide on how to create many visualizations with Plotly Express with layout styling, interactivity, animations, and many chart ...
Read more >
panel.pane Package — Panel v0.14.2
This does not allow using all types of parameters. ... DataFrame(df, index=False, max_rows=25, width=400) ... An int is assumed to be px units....
Read more >
Dash User Guide and Documentation
styles were optimized to look good on the web and in PDF form. ... The callback does not modify the original data, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found