From 07638aa22738616dfe34a7ca42e109b2944e8bac Mon Sep 17 00:00:00 2001 From: JJ Robertson Date: Fri, 13 May 2022 22:16:16 -0700 Subject: [PATCH 1/2] Fix add_vline with text annotation --- packages/python/plotly/plotly/shapeannotation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/python/plotly/plotly/shapeannotation.py b/packages/python/plotly/plotly/shapeannotation.py index a2323ed02d..887ff14a79 100644 --- a/packages/python/plotly/plotly/shapeannotation.py +++ b/packages/python/plotly/plotly/shapeannotation.py @@ -4,6 +4,10 @@ def _mean(x): if len(x) == 0: raise ValueError("x must have positive length") + # Mean of two of the same elements will just be that element. + # This fixes this https://github.com/plotly/plotly.py/issues/3065 + if len(x) == 2 and x[0] == x[1]: + return x[0] return float(sum(x)) / len(x) From 5af1ce529467fae671d3ebe9dce1aee07d3c7b6f Mon Sep 17 00:00:00 2001 From: JJ Robertson Date: Fri, 13 May 2022 22:32:46 -0700 Subject: [PATCH 2/2] Update shapeannotation.py --- packages/python/plotly/plotly/shapeannotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/shapeannotation.py b/packages/python/plotly/plotly/shapeannotation.py index 887ff14a79..acf6dfe725 100644 --- a/packages/python/plotly/plotly/shapeannotation.py +++ b/packages/python/plotly/plotly/shapeannotation.py @@ -5,7 +5,7 @@ def _mean(x): if len(x) == 0: raise ValueError("x must have positive length") # Mean of two of the same elements will just be that element. - # This fixes this https://github.com/plotly/plotly.py/issues/3065 + # This fixes https://github.com/plotly/plotly.py/issues/3065 if len(x) == 2 and x[0] == x[1]: return x[0] return float(sum(x)) / len(x)