Skip to content

Commit 3595861

Browse files
committed
DOC: Improve description of background/bbox handling for Text
1 parent 33dbc47 commit 3595861

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/matplotlib/text.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,21 @@ def _get_layout(self, renderer):
516516

517517
def set_bbox(self, rectprops):
518518
"""
519-
Draw a bounding box around self.
519+
Draw a box behind/around the text.
520+
521+
This can be used to set a background and/or a frame around the text.
522+
It's realized through a `.FancyBboxPatch` behind the text (see also
523+
`.Text.get_bbox_patch`). The bbox patch is None by default and only
524+
created when needed.
520525
521526
Parameters
522527
----------
523-
rectprops : dict with properties for `.patches.FancyBboxPatch`
528+
rectprops : dict with properties for `.FancyBboxPatch` or None
524529
The default boxstyle is 'square'. The mutation
525530
scale of the `.patches.FancyBboxPatch` is set to the fontsize.
526531
532+
Pass ``None`` to remove the bbox patch completely.
533+
527534
Examples
528535
--------
529536
::
@@ -558,6 +565,8 @@ def get_bbox_patch(self):
558565
"""
559566
Return the bbox Patch, or None if the `.patches.FancyBboxPatch`
560567
is not made.
568+
569+
For more details see `.Text.set_bbox`.
561570
"""
562571
return self._bbox_patch
563572

@@ -981,7 +990,10 @@ def get_window_extent(self, renderer=None, dpi=None):
981990

982991
def set_backgroundcolor(self, color):
983992
"""
984-
Set the background color of the text by updating the bbox.
993+
Set the background color of the text.
994+
995+
This is realized through the bbox (see `.set_bbox`),
996+
creating the bbox patch if needed.
985997
986998
Parameters
987999
----------

0 commit comments

Comments
 (0)