19
19
from matplotlib .cbook import is_string_like , maxdict
20
20
from matplotlib import docstring
21
21
from matplotlib .font_manager import FontProperties
22
- from matplotlib .patches import bbox_artist , YAArrow , FancyBboxPatch
22
+ from matplotlib .patches import YAArrow , FancyBboxPatch
23
23
from matplotlib .patches import FancyArrowPatch , Rectangle
24
24
import matplotlib .transforms as mtransforms
25
25
from matplotlib .transforms import Affine2D , Bbox , Transform
@@ -446,25 +446,19 @@ def _get_layout(self, renderer):
446
446
def set_bbox (self , rectprops ):
447
447
"""
448
448
Draw a bounding box around self. rectprops are any settable
449
- properties for a rectangle , e.g., facecolor='red', alpha=0.5.
449
+ properties for a FancyBboxPatch , e.g., facecolor='red', alpha=0.5.
450
450
451
451
t.set_bbox(dict(facecolor='red', alpha=0.5))
452
452
453
- If rectprops has "boxstyle" key. A FancyBboxPatch
454
- is initialized with rectprops and will be drawn. The mutation
455
- scale of the FancyBboxPath is set to the fontsize.
453
+ The default boxstyle is 'square'. The mutation
454
+ scale of the FancyBboxPatch is set to the fontsize.
456
455
457
- ACCEPTS: rectangle prop dict
456
+ ACCEPTS: FancyBboxPatch prop dict
458
457
"""
459
458
460
- # The self._bbox_patch object is created only if rectprops has
461
- # boxstyle key. Otherwise, self._bbox will be set to the
462
- # rectprops and the bbox will be drawn using bbox_artist
463
- # function. This is to keep the backward compatibility.
464
-
465
- if rectprops is not None and "boxstyle" in rectprops :
459
+ if rectprops is not None :
466
460
props = rectprops .copy ()
467
- boxstyle = props .pop ("boxstyle" )
461
+ boxstyle = props .pop ("boxstyle" , "square" )
468
462
bbox_transmuter = props .pop ("bbox_transmuter" , None )
469
463
470
464
self ._bbox_patch = FancyBboxPatch (
@@ -474,10 +468,8 @@ def set_bbox(self, rectprops):
474
468
bbox_transmuter = bbox_transmuter ,
475
469
transform = mtransforms .IdentityTransform (),
476
470
** props )
477
- self ._bbox = None
478
471
else :
479
472
self ._bbox_patch = None
480
- self ._bbox = rectprops
481
473
482
474
self ._update_clip_properties ()
483
475
@@ -519,7 +511,7 @@ def update_bbox_position_size(self, renderer):
519
511
def _draw_bbox (self , renderer , posx , posy ):
520
512
521
513
""" Update the location and the size of the bbox
522
- (FancyBoxPatch ), and draw
514
+ (FancyBboxPatch ), and draw
523
515
"""
524
516
525
517
x_box , y_box , w_box , h_box = _get_textbox (self , renderer )
@@ -537,8 +529,6 @@ def _update_clip_properties(self):
537
529
clip_path = self ._clippath ,
538
530
clip_on = self ._clipon )
539
531
540
- if self ._bbox :
541
<
10000
/td>- bbox = self ._bbox .update (clipprops )
542
532
if self ._bbox_patch :
543
533
bbox = self ._bbox_patch .update (clipprops )
544
534
@@ -622,8 +612,6 @@ def draw(self, renderer):
622
612
gc .set_url (self ._url )
623
613
self ._set_gc_clip (gc )
624
614
625
- if self ._bbox :
626
- bbox_artist (self , renderer , self ._bbox )
627
615
angle = self .get_rotation ()
628
616
629
617
for line , wh , x , y in info :
@@ -825,10 +813,10 @@ def set_backgroundcolor(self, color):
825
813
826
814
ACCEPTS: any matplotlib color
827
815
"""
828
- if self ._bbox is None :
829
- self ._bbox = dict (facecolor = color , edgecolor = color )
816
+ if self ._bbox_patch is None :
817
+ self .set_bbox = dict (facecolor = color , edgecolor = color )
830
818
else :
831
- self ._bbox .update (dict (facecolor = color ))
819
+ self ._bbox_patch .update (dict (facecolor = color ))
832
820
833
821
self ._update_clip_properties ()
834
822
@@ -1985,13 +1973,7 @@ def _update_position_xytext(self, renderer, xy_pixel):
1985
1973
if self ._bbox_patch :
1986
1974
self .arrow_patch .set_patchA (self ._bbox_patch )
1987
1975
else :
1988
- props = self ._bbox
1989
- if props is None :
1990
- props = {}
1991
- # don't want to alter the pad externally
1992
- props = props .copy ()
1993
- pad = props .pop ('pad' , 4 )
1994
- pad = renderer .points_to_pixels (pad )
1976
+ pad = renderer .points_to_pixels (4 )
1995
1977
if self .get_text ().strip () == "" :
1996
1978
self .arrow_patch .set_patchA (None )
1997
1979
return
@@ -2008,12 +1990,11 @@ def _update_position_xytext(self, renderer, xy_pixel):
2008
1990
)
2009
1991
r .set_transform (mtransforms .IdentityTransform ())
2010
1992
r .set_clip_on (False )
2011
- r .update (props )
2012
1993
2013
1994
self .arrow_patch .set_patchA (r )
2014
1995
2015
1996
else :
2016
-
1997
+ # using YAArrow
2017
1998
# pick the x,y corner of the text bbox closest to point
2018
1999
# annotated
2019
2000
dsu = [(abs (val - x0 ), val ) for val in (l , r , xc )]
0 commit comments