@@ -25,12 +25,12 @@ def annotation_params_for_line(shape_type, shape_args, position):
25
25
M = "middle"
26
26
aY = max (Y )
27
27
iY = min (Y )
28
- mY = mean (Y )
28
+ eY = mean (Y )
29
29
aaY = argmax (Y )
30
30
aiY = argmin (Y )
31
31
aX = max (X )
32
32
iX = min (X )
33
- mX = mean (X )
33
+ eX = mean (X )
34
34
aaX = argmax (X )
35
35
aiX = argmin (X )
36
36
@@ -58,13 +58,13 @@ def annotation_params_for_line(shape_type, shape_args, position):
58
58
if position == "top right" :
59
59
return _df_anno (R , B , aX , Y [aaX ])
60
60
if position == "top" :
61
- return _df_anno (C , B , mX , mY )
61
+ return _df_anno (C , B , eX , eY )
62
62
if position == "bottom left" :
63
63
return _df_anno (L , T , iX , Y [aiX ])
64
64
if position == "bottom right" :
65
65
return _df_anno (R , T , aX , Y [aaX ])
66
66
if position == "bottom" :
67
- return _df_anno (C , T , mX , mY )
67
+ return _df_anno (C , T , eX , eY )
68
68
if position == "left" :
69
69
return _df_anno (R , M , iX , Y [aiX ])
70
70
if position == "right" :
@@ -98,15 +98,35 @@ def annotation_params_for_rect(shape_type, shape_args, position):
98
98
# TODO: Do we want this?
99
99
return _df_anno ("center" , "middle" , mean ([x0 , x1 ]), mean ([y0 , y1 ]))
100
100
if position == "outside top left" :
101
- return _df_anno ("right" , "bottom" , min ([x0 , x1 ]), max ([y0 , y1 ]))
101
+ return _df_anno (
102
+ "right" if shape_type == "vrect" else "left" ,
103
+ "bottom" if shape_type == "hrect" else "top" ,
104
+ min ([x0 , x1 ]),
105
+ max ([y0 , y1 ]),
106
+ )
102
107
if position == "outside top right" :
103
- return _df_anno ("left" , "bottom" , max ([x0 , x1 ]), max ([y0 , y1 ]))
108
+ return _df_anno (
109
+ "left" if shape_type == "vrect" else "right" ,
110
+ "bottom" if shape_type == "hrect" else "top" ,
111
+ max ([x0 , x1 ]),
112
+ max ([y0 , y1 ]),
113
+ )
104
114
if position == "outside top" :
105
115
return _df_anno ("center" , "bottom" , mean ([x0 , x1 ]), max ([y0 , y1 ]))
106
116
if position == "outside bottom left" :
107
- return _df_anno ("right" , "top" , min ([x0 , x1 ]), min ([y0 , y1 ]))
117
+ return _df_anno (
118
+ "right" if shape_type == "vrect" else "left" ,
119
+ "top" if shape_type == "hrect" else "bottom" ,
120
+ min ([x0 , x1 ]),
121
+ min ([y0 , y1 ]),
122
+ )
108
123
if position == "outside bottom right" :
109
- return _df_anno ("left" , "top" , max ([x0 , x1 ]), min ([y0 , y1 ]))
124
+ return _df_anno (
125
+ "left" if shape_type == "vrect" else "right" ,
126
+ "top" if shape_type == "hrect" else "bottom" ,
127
+ max ([x0 , x1 ]),
128
+ min ([y0 , y1 ]),
129
+ )
110
130
if position == "outside bottom" :
111
131
return _df_anno ("center" , "top" , mean ([x0 , x1 ]), min ([y0 , y1 ]))
112
132
if position == "outside left" :
@@ -141,11 +161,8 @@ def axis_spanning_shape_annotation(annotation, shape_type, shape_args, kwargs):
141
161
annotation_position, annotation_ prefixed kwargs or the original annotation
142
162
passed in to this function.
143
163
"""
144
- # Force to go.layout.Annotation, no matter if it is that already, a dict or None
145
- # TODO: We can't import go.layout.Annotation so we initialize this as a
146
- # dict. This strategy is inferior to initializing as a go.layout.Annotation
147
- # because there's no checking if a key is valid. Eventually it'd be better
148
- # to use go.layout.Annotation.
164
+ # TODO: Would it be better if annotation were initialized to an instace of
165
+ # go.layout.Annotation ?
149
166
if annotation is None :
150
167
annotation = dict ()
151
168
# set properties based on annotation_ prefixed kwargs
0 commit comments