Error on using add_vline with text annotation for data with date-time x axis
See original GitHub issueHi, I am trying to use the library for a simple visualisation for the first time, and I stumbled upon supposedly a bug trying to draw a vertical line with text annotation on a graph with a date-time x axis.
import plotly.express as px
df = px.data.stocks(indexed=True)
fig = px.line(df)
fig.add_vline(x="2018-09-24", annotation_text="test" )
fig.show()
I get the following error message:
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Could anyone please help me confirm that it is indeed a bug, my version is ‘4.14.1’ ? Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:24
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Add_vline with annotation and datetime as x-axis - Plotly Python
I'm using datetime objects as x-axis values, no problem there. ... Error on using add_vline with text annotation for data with date-time x ......
Read more >Adding annotation text yields integer error message
When I adding a vline to my graph it works perfect: fig.add_vline( x=pd.
Read more >Error on using add_vline with text annotation for data with date ...
Error on using add_vline with text annotation for data with date-time x axis ... Hi, I am trying to use the library for...
Read more >Releases — HoloViews v1.15.3
Fixed xaxis/yaxis options with Matplotlib (#5200). Fixed nested widgets by handling list or ... Fix Bars legend error when overlaid with annotation (#5142)....
Read more >Convert Unix Timestamp With Bokeh Plotting X Axis - ADocLib
When I plot using fplt.plotdf['timestamp' df['MyIndicator']] the x axis ... Error on using addvline with text annotation for data with datetime x axis...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @MR0205,
If you’re looking for a temporary workaround, you can get the annotation to work by converting your
x
value into milliseconds since epoch as follows:The above suggestion from @awrobel1 was great for me. In my case I simplified a tad with
x=datetime.datetime(2021,5,27).timestamp() * 1000
. No need to convert from a string first in this case.