Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plotly/shapeannotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
def _mean(x):
if len(x) == 0:
raise ValueError("x must have positive length")
return float(sum(x)) / len(x)
# Handle non-numeric values (e.g., date strings)
# For vline/hline, x0==x1 and y0==y1, so returning first value is correct
try:
return float(sum(x)) / len(x)
except TypeError:
# If sum fails (e.g., for date strings), return the first value
# This works because for vlines x0==x1, and for hlines y0==y1
return x[0]


def _argmin(x):
Expand Down