Closed
Description
I am trying to show an hline or vline on a time series.
import datetime
import plotly.graph_objects as go
figure = go.Figure()
figure.update_layout(
yaxis=dict(
type="date",
tickformat='%H:%M',
)
)
figure.add_hline(
annotation_text="Recommended Daily Intake",
y=datetime.datetime.now(),
)
The error I get:
File "..../.venv/lib/python3.9/site-packages/plotly/shapeannotation.py", line 7, in _mean
return float(sum(x)) / len(x)
TypeError: unsupported operand type(s) for +: 'int' and 'datetime.datetime'
x is:
>>> print(x)
[datetime.datetime(2021, 12, 2, 14, 3, 29, 780450), datetime.datetime(2021, 12, 2, 14, 3, 29, 780450)]
Which means that sum does not work with datetime.datetime
:
>>> sum([datetime.datetime(2021, 12, 2, 14, 3, 29, 780450), datetime.datetime(2021, 12, 2, 14, 3, 29, 780450)])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'datetime.datetime'
Metadata
Metadata
Assignees
Labels
No labels