Bar plot hover shows incorrect bar length when base is used
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Hello,
I tried making something like a Gantt chart and use the Bar plot type for that. It seems the hover effect is mixing up the columns somehow. Here is a minimal reproduction:
import pandas as pd
import plotly.express as px
gantt = []
gantt.append(dict(Begin=0, End=1, Word='Foo'))
gantt.append(dict(Begin=2, End=5, Word='Bar'))
gantt_df = pd.DataFrame(gantt)
gantt_df['Duration'] = (gantt_df['End'] - gantt_df['Begin'])
fig = px.bar(gantt_df, base="Begin", y="Duration", x="Word")
fig.show()
Here is the result:
Things of note:
- The position and size of the bars is correct
- The "Begin" annotation in the hover is correct
- The "Duration" annotation shows the value of the "End" column, which is not correct. I would expect "End=5" or "Duration=3" but not "Duration=5"
Examining the pandas dataframe itself shows that the data itself is correct:
This is my version according to conda:
plotly 5.23.0 pyhd8ed1ab_0 conda-forge
Thank you for providing this great library for free and I hope that you find my report helpful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal pandas and plotly.express reproduction from the issue with plotly 5.23.0 and compare the rendered bar hover fields against Begin, End, and Duration in the dataframe. The work is done when the bar positions remain correct and hover displays the expected duration value rather than End.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100