@@ -25,12 +25,12 @@ def annotation_params_for_line(shape_type, shape_args, position):
2525 M = "middle"
2626 aY = max (Y )
2727 iY = min (Y )
28- mY = mean (Y )
28+ eY = mean (Y )
2929 aaY = argmax (Y )
3030 aiY = argmin (Y )
3131 aX = max (X )
3232 iX = min (X )
33- mX = mean (X )
33+ eX = mean (X )
3434 aaX = argmax (X )
3535 aiX = argmin (X )
3636
@@ -58,13 +58,13 @@ def annotation_params_for_line(shape_type, shape_args, position):
5858 if position == "top right" :
5959 return _df_anno (R , B , aX , Y [aaX ])
6060 if position == "top" :
61- return _df_anno (C , B , mX , mY )
61+ return _df_anno (C , B , eX , eY )
6262 if position == "bottom left" :
6363 return _df_anno (L , T , iX , Y [aiX ])
6464 if position == "bottom right" :
6565 return _df_anno (R , T , aX , Y [aaX ])
6666 if position == "bottom" :
67- return _df_anno (C , T , mX , mY )
67+ return _df_anno (C , T , eX , eY )
6868 if position == "left" :
6969 return _df_anno (R , M , iX , Y [aiX ])
7070 if position == "right" :
@@ -98,15 +98,35 @@ def annotation_params_for_rect(shape_type, shape_args, position):
9898 # TODO: Do we want this?
9999 return _df_anno ("center" , "middle" , mean ([x0 , x1 ]), mean ([y0 , y1 ]))
100100 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+ )
102107 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+ )
104114 if position == "outside top" :
105115 return _df_anno ("center" , "bottom" , mean ([x0 , x1 ]), max ([y0 , y1 ]))
106116 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+ )
108123 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+ )
110130 if position == "outside bottom" :
111131 return _df_anno ("center" , "top" , mean ([x0 , x1 ]), min ([y0 , y1 ]))
112132 if position == "outside left" :
@@ -141,11 +161,8 @@ def axis_spanning_shape_annotation(annotation, shape_type, shape_args, kwargs):
141161 annotation_position, annotation_ prefixed kwargs or the original annotation
142162 passed in to this function.
143163 """
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 ?
149166 if annotation is None :
150167 annotation = dict ()
151168 # set properties based on annotation_ prefixed kwargs
0 commit comments