We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to annotate my plot following https://plotly.com/python/horizontal-vertical-shapes/ , but I get
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported.
my dataframe index is of type <M8[ns]
<M8[ns]
(it works without annotation_text)
annotation_text
ps: plotly Version: 5.10.0
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Input In [82], in <cell line: 4>() 2 fig.update_layout(yaxis_title=r"uV") 4 for time, text, color in zip(times_list_1, condi_list, color_list): ----> 6 fig.add_vline(x=time, annotation_text = text) # , annotation_position='bottom' 8 # plt.text(time, (y_min + y_max) /2 , text, c=color) 9 10 # fig.show() 12 fig.write_html('session1_resam_mean.html') File /usr/local/lib/python3.9/site-packages/plotly/graph_objs/_figure.py:1013, in Figure.add_vline(self, x, row, col, exclude_empty_subplots, annotation, **kwargs) 965 def add_vline( 966 self, 967 x, (...) 972 **kwargs, 973 ) -> "Figure": 974 """ 975 976 Add a vertical line to a plot or subplot that extends infinitely in the (...) 1011 except for x0, x1, y0, y1 or type. 1012 """ -> 1013 return super(Figure, self).add_vline( 1014 x, row, col, exclude_empty_subplots, annotation, **kwargs 1015 ) File /usr/local/lib/python3.9/site-packages/plotly/basedatatypes.py:4086, in BaseFigure.add_vline(self, x, row, col, exclude_empty_subplots, annotation, **kwargs) 4077 def add_vline( 4078 self, 4079 x, (...) 4084 **kwargs, 4085 ): -> 4086 self._process_multiple_axis_spanning_shapes( 4087 dict(type="line", x0=x, x1=x, y0=0, y1=1), 4088 row, 4089 col, 4090 "vline", 4091 exclude_empty_subplots=exclude_empty_subplots, 4092 annotation=annotation, 4093 **kwargs, 4094 ) 4095 return self File /usr/local/lib/python3.9/site-packages/plotly/basedatatypes.py:4031, in BaseFigure._process_multiple_axis_spanning_shapes(self, shape_args, row, col, shape_type, exclude_empty_subplots, annotation, **kwargs) 4022 # shapes are always added at the end of the tuple of shapes, so we see 4023 # how long the tuple is before the call and after the call, and adjust 4024 # the new shapes that were added at the end 4025 # extract annotation prefixed kwargs 4026 # annotation with extra parameters based on the annotation_position 4027 # argument and other annotation_ prefixed kwargs 4028 shape_kwargs, annotation_kwargs = shapeannotation.split_dict_by_key_prefix( 4029 kwargs, "annotation_" 4030 ) -> 4031 augmented_annotation = shapeannotation.axis_spanning_shape_annotation( 4032 annotation, shape_type, shape_args, annotation_kwargs 4033 ) 4034 self.add_shape( 4035 row=row, 4036 col=col, 4037 exclude_empty_subplots=exclude_empty_subplots, 4038 **_combine_dicts([shape_args, shape_kwargs]), 4039 ) 4040 if augmented_annotation is not None: File /usr/local/lib/python3.9/site-packages/plotly/shapeannotation.py:216, in axis_spanning_shape_annotation(annotation, shape_type, shape_args, kwargs) 214 annotation_position = kwargs["annotation_position"] 215 if shape_type.endswith("line"): --> 216 shape_dict = annotation_params_for_line( 217 shape_type, shape_args, annotation_position 218 ) 219 elif shape_type.endswith("rect"): 220 shape_dict = annotation_params_for_rect( 221 shape_type, shape_args, annotation_position 222 ) File /usr/local/lib/python3.9/site-packages/plotly/shapeannotation.py:63, in annotation_params_for_line(shape_type, shape_args, position) 61 aX = max(X) 62 iX = min(X) ---> 63 eX = _mean(X) 64 aaX = _argmax(X) 65 aiX = _argmin(X) File /usr/local/lib/python3.9/site-packages/plotly/shapeannotation.py:7, in _mean(x) 5 if len(x) == 0: 6 raise ValueError("x must have positive length") ----> 7 return float(sum(x)) / len(x) File /usr/local/lib/python3.9/site-packages/pandas/_libs/tslibs/timestamps.pyx:311, in pandas._libs.tslibs.timestamps._Timestamp.__add__() File /usr/local/lib/python3.9/site-packages/pandas/_libs/tslibs/timestamps.pyx:296, in pandas._libs.tslibs.timestamps._Timestamp.__add__() TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
The text was updated successfully, but these errors were encountered:
a similar issue, is already discussed in #3065 ... but it's slightly different
Sorry, something went wrong.
No branches or pull requests
I am trying to annotate my plot following https://plotly.com/python/horizontal-vertical-shapes/ , but I get
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported.
my dataframe index is of type
<M8[ns]
(it works without
annotation_text
)ps: plotly Version: 5.10.0
here is the full log
The text was updated successfully, but these errors were encountered: