def _get_textbox(text, renderer):
 projected_xs = []
 projected_ys = []
 theta = np.deg2rad(text.get_rotation())
 tr = mtransforms.Affine2D().rotate((- theta))
 (_, parts, d) = text._get_layout(renderer)
 for (t, wh, x, y) in parts:
  (w, h) = wh
  (xt1, yt1) = tr.transform_point((x, y))
  yt1 -= d
  (xt2, yt2) = ((xt1 + w), (yt1 + h))
  projected_xs.extend([xt1, xt2])
  projected_ys.extend([yt1, yt2])
 (xt_box, yt_box) = (min(projected_xs), min(projected_ys))
 (w_box, h_box) = ((max(projected_xs) - xt_box), (max(projected_ys) - yt_box))
 tr = mtransforms.Affine2D().rotate(theta)
 (x_box, y_box) = tr.transform_point((xt_box, yt_box))
 return (x_box, y_box, w_box, h_box)

def _get_textbox ( text , renderer ) : projected_xs = [ ] projected_ys = [ ] theta = np . deg2rad ( text . get_rotation ( ) ) tr = mtransforms . Affine2D ( ) . rotate ( ( - theta ) ) ( _ , parts , d ) = text . _get_layout ( renderer ) for ( t , wh , x , y ) in parts : ( w , h ) = wh ( xt1 , yt1 ) = tr . transform_point ( ( x , y ) ) yt1 -= d ( xt2 , yt2 ) = ( ( xt1 + w ) , ( yt1 + h ) ) projected_xs . extend ( [ xt1 , xt2 ] ) projected_ys . extend ( [ yt1 , yt2 ] ) ( xt_box , yt_box ) = ( min ( projected_xs ) , min ( projected_ys ) ) ( w_box , h_box ) = ( ( max ( projected_xs ) - xt_box ) , ( max ( projected_ys ) - yt_box ) ) tr = mtransforms . Affine2D ( ) . rotate ( theta ) ( x_box , y_box ) = tr . transform_point ( ( xt_box , yt_box ) ) return ( x_box , y_box , w_box , h_box )
calculate the bounding box of the text .