21
21
from matplotlib .cbook import is_string_like , maxdict
22
22
from matplotlib import docstring
23
23
from matplotlib .font_manager import FontProperties
24
- from matplotlib .patches import bbox_artist , YAArrow , FancyBboxPatch
24
+ from matplotlib .patches import YAArrow , FancyBboxPatch
25
25
from matplotlib .patches import FancyArrowPatch , Rectangle
26
26
import matplotlib .transforms as mtransforms
27
27
from matplotlib .transforms import Affine2D , Bbox , Transform
@@ -469,25 +469,19 @@ def _get_layout(self, renderer):
469
469
def set_bbox (self , rectprops ):
470
470
"""
471
471
Draw a bounding box around self. rectprops are any settable
472
- properties for a rectangle , e.g., facecolor='red', alpha=0.5.
472
+ properties for a FancyBboxPatch , e.g., facecolor='red', alpha=0.5.
473
473
474
474
t.set_bbox(dict(facecolor='red', alpha=0.5))
475
475
476
- If rectprops has "boxstyle" key. A FancyBboxPatch
477
- is initialized with rectprops and will be drawn. The mutation
478
- scale of the FancyBboxPath is set to the fontsize.
476
+ The default boxstyle is 'square'. The mutation
477
+ scale of the FancyBboxPatch is set to the fontsize.
479
478
480
- ACCEPTS: rectangle prop dict
479
+ ACCEPTS: FancyBboxPatch prop dict
481
480
"""
482
481
483
- # The self._bbox_patch object is created only if rectprops has
484
- # boxstyle key. Otherwise, self._bbox will be set to the
485
- # rectprops and the bbox will be drawn using bbox_artist
486
- # function. This is to keep the backward compatibility.
487
-
488
- if rectprops is not None and "boxstyle" in rectprops :
482
+ if rectprops is not None :
489
483
props = rectprops .copy ()
490
- boxstyle = props .pop ("boxstyle" )
484
+ boxstyle = props .pop ("boxstyle" , "square" )
491
485
bbox_transmuter = props .pop ("bbox_transmuter" , None )
492
486
493
487
self ._bbox_patch = FancyBboxPatch (
@@ -497,10 +491,8 @@ def set_bbox(self, rectprops):
497
491
bbox_transmuter = bbox_transmuter ,
498
492
transform = mtransforms .IdentityTransform (),
499
493
** props )
500
- self ._bbox = None
501
494
else :
502
495
self ._bbox_patch = None
503
- self ._bbox = rectprops
504
496
505
497
self ._update_clip_properties ()
506
498
@@ -542,7 +534,7 @@ def update_bbox_position_size(self, renderer):
542
534
def _draw_bbox (self , renderer , posx , posy ):
543
535
544
536
""" Update the location and the size of the bbox
545
- (FancyBoxPatch ), and draw
537
+ (FancyBboxPatch ), and draw
546
538
"""
547
539
548
540
x_box , y_box , w_box , h_box = _get_textbox (self , renderer )
@@ -560,8 +552,6 @@ def _update_clip_properties(self):
560
552
clip_path = self ._clippath ,
561
553
clip_on = self ._clipon )
562
554
563
- if self ._bbox :
564
- bbox = self ._bbox .update (clipprops )
565
555
if self ._bbox_patch :
566
556
bbox = self ._bbox_patch .update (clipprops )
567
557
@@ -756,8 +746,6 @@ def draw(self, renderer):
756
746
gc .set_url (textobj ._url )
757
747
textobj ._set_gc_clip (gc )
758
748
759
- if textobj ._bbox :
760
- bbox_artist (textobj , renderer , textobj ._bbox )
761
749
angle = textobj .get_rotation ()
762
750
763
751
for line , wh , x , y in info :
@@ -959,10 +947,10 @@ def set_backgroundcolor(self, color):
959
947
960
948
ACCEPTS: any matplotlib color
961
949
"""
962
- if self ._bbox is None :
963
- self ._bbox = dict (facecolor = color , edgecolor = color )
950
+ if self ._bbox_patch is None :
951
+ self .set_bbox = dict (facecolor = color , edgecolor = color )
964
952
else :
965
- self ._bbox .update (dict (facecolor = color ))
953
+ self ._bbox_patch .update (dict (facecolor = color ))
966
954
967
955
self ._update_clip_properties ()
968
956
self .stale = True
@@ -2147,13 +2135,7 @@ def _update_position_xytext(self, renderer, xy_pixel):
2147
2135
if self ._bbox_patch :
2148
2136
self .arrow_patch .set_patchA (self ._bbox_patch )
2149
2137
else :
2150
- props = self ._bbox
2151
- if props is None :
2152
- props = {}
2153
- # don't want to alter the pad externally
2154
- props = props .copy ()
2155
- pad = props .pop ('pad' , 4 )
2156
- pad = renderer .points_to_pixels (pad )
2138
+ pad = renderer .points_to_pixels (4 )
2157
2139
if self .get_text ().strip () == "" :
2158
2140
self .arrow_patch .set_patchA (None )
2159
2141
return
@@ -2170,12 +2152,11 @@ def _update_position_xytext(self, renderer, xy_pixel):
2170
2152
)
2171
2153
r .set_transform (mtransforms .IdentityTransform ())
2172
2154
r .set_clip_on (False )
2173
- r .update (props )
2174
2155
2175
2156
self .arrow_patch .set_patchA (r )
2176
2157
2177
2158
else :
2178
-
2159
+ # using YAArrow
2179
2160
# pick the x,y corner of the text bbox closest to point
2180
2161
# annotated
2181
2162
dsu = [(abs (val - x0 ), val ) for val in (l , r , xc )]
0 commit comments