Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6223d19

Browse files
committed
changed docstrings in Text
1 parent d4f1f8d commit 6223d19

File tree

1 file changed

+123
-43
lines changed

1 file changed

+123
-43
lines changed

lib/matplotlib/text.py

Lines changed: 123 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self,
143143
**kwargs
144144
):
145145
"""
146-
Create a `Text` instance at *x*, *y* with string *text*.
146+
Create a `.Text` instance at *x*, *y* with string *text*.
147147
148148
Valid kwargs are
149149
%(Text)s
@@ -200,7 +200,9 @@ def contains(self, mouseevent):
200200
In the case of text, a hit is true anywhere in the
201201
axis-aligned bounding-box containing the text.
202202
203-
Returns True or False.
203+
Returns
204+
-------
205+
bool : bool
204206
"""
205207
if callable(self._contains):
206208
return self._contains(self, mouseevent)
@@ -430,17 +432,19 @@ def _get_layout(self, renderer):
430432

431433
def set_bbox(self, rectprops):
432434
"""
433-
Draw a bounding box around self. rectprops are any settable
434-
properties for a FancyBboxPatch, e.g., facecolor='red', alpha=0.5.
435-
436-
t.set_bbox(dict(facecolor='red', alpha=0.5))
437-
438-
The default boxstyle is 'square'. The mutation
439-
scale of the FancyBboxPatch is set to the fontsize.
435+
Draw a bounding box around self.
440436
441437
Parameters
442438
----------
443-
rectprops : FancyBboxPatch prop dict
439+
rectprops : dict with properties for `.patches.FancyBboxPatch`
440+
The default boxstyle is 'square'. The mutation
441+
scale of the `.patches.FancyBboxPatch` is set to the fontsize.
442+
443+
Examples
444+
--------
445+
::
446+
447+
t.set_bbox(dict(facecolor='red', alpha=0.5))
444448
"""
445449

446450
if rectprops is not None:
@@ -476,7 +480,8 @@ def set_bbox(self, rectprops):
476480

477481
def get_bbox_patch(self):
478482
"""
479-
Return the bbox Patch, or None if the FancyBboxPatch is not made.
483+
Return the bbox Patch, or None if the `.patches.FancyBboxPatch`
484+
is not made.
480485
"""
481486
return self._bbox_patch
482487

@@ -510,7 +515,8 @@ def update_bbox_position_size(self, renderer):
510515

511516
def _draw_bbox(self, renderer, posx, posy):
512517
"""
513-
Update the location and size of the bbox (FancyBboxPatch), and draw.
518+
Update the location and size of the bbox (`.patches.FancyBboxPatch`),
519+
and draw.
514520
"""
515521

516522
x_box, y_box, w_box, h_box = _get_textbox(self, renderer)
@@ -532,11 +538,11 @@ def _update_clip_properties(self):
532538

533539
def set_clip_box(self, clipbox):
534540
"""
535-
Set the artist's clip :class:`~matplotlib.transforms.Bbox`.
541+
Set the artist's clip `~.transforms.Bbox`.
536542
537543
Parameters
538544
----------
539-
clipbox : matplotlib.transforms.Bbox
545+
clipbox : `matplotlib.transforms.Bbox`
540546
"""
541547
super().set_clip_box(clipbox)
542548
self._update_clip_properties()
@@ -545,10 +551,10 @@ def set_clip_path(self, path, transform=None):
545551
"""
546552
Set the artist's clip path, which may be:
547553
548-
* a :class:`~matplotlib.patches.Patch` (or subclass) instance
554+
* a `~matplotlib.patches.Patch` (or subclass) instance
549555
550-
* a :class:`~matplotlib.path.Path` instance, in which case
551-
an optional :class:`~matplotlib.transforms.Transform`
556+
* a `~matplotlib.path.Path` instance, in which case
557+
an optional `~matplotlib.transforms.Transform`
552558
instance may be provided, which will be applied to the
553559
path before using it for clipping.
554560
@@ -558,9 +564,9 @@ def set_clip_path(self, path, transform=None):
558564
rectangle, this method will set the clipping box to the
559565
corresponding rectangle and set the clipping path to *None*.
560566
561-
ACCEPTS: [ (:class:`~matplotlib.path.Path`,
562-
:class:`~matplotlib.transforms.Transform`) |
563-
:class:`~matplotlib.patches.Patch` | None ]
567+
ACCEPTS: [ (`~matplotlib.path.Path`,
568+
`~matplotlib.transforms.Transform`) |
569+
`~matplotlib.patches.Patch` | None ]
564570
"""
565571
super().set_clip_path(path, transform)
566572
self._update_clip_properties()
@@ -689,7 +695,7 @@ def _get_wrapped_text(self):
689695
@artist.allow_rasterization
690696
def draw(self, renderer):
691697
"""
692-
Draws the :class:`Text` object to the given *renderer*.
698+
Draws the `.Text` object to the given *renderer*.
693699
"""
694700
if renderer is not None:
695701
self._renderer = renderer
@@ -761,35 +767,77 @@ def get_color(self):
761767
return self._color
762768

763769
def get_fontproperties(self):
764-
"Return the :class:`~font_manager.FontProperties` object"
770+
"Return the `.font_manager.FontProperties` object"
765771
return self._fontproperties
766772

767773
def get_fontfamily(self):
768-
"Return the list of font families used for font lookup"
774+
"""
775+
Return the list of font families used for font lookup
776+
777+
See Also
778+
--------
779+
.font_manager.FontProperties.get_family
780+
"""
769781
return self._fontproperties.get_family()
770782

771783
def get_fontname(self):
772-
"Return the font name as string"
784+
"""
785+
Return the font name as string
786+
787+
See Also
788+
--------
789+
.font_manager.FontProperties.get_name
790+
"""
773791
return self._fontproperties.get_name()
774792

775793
def get_fontstyle(self):
776-
"Return the font style as string"
794+
"""
795+
Return the font style as string
796+
797+
See Also
798+
--------
799+
.font_manager.FontProperties.get_style
800+
"""
777801
return self._fontproperties.get_style()
778802

779803
def get_fontsize(self):
780-
"Return the font size as integer"
804+
"""
805+
Return the font size as integer
806+
807+
See Also
808+
--------
809+
.font_manager.FontProperties.get_size_in_points
810+
"""
781811
return self._fontproperties.get_size_in_points()
782812

783813
def get_fontvariant(self):
784-
"Return the font variant as a string"
814+
"""
815+
Return the font variant as a string
816+
817+
See Also
818+
--------
819+
.font_manager.FontProperties.get_variant
820+
"""
785821
return self._fontproperties.get_variant()
786822

787823
def get_fontweight(self):
788-
"Get the font weight as string or number"
824+
"""
825+
Get the font weight as string or number
826+
827+
See Also
828+
--------
829+
.font_manager.FontProperties.get_weight
830+
"""
789831
return self._fontproperties.get_weight()
790832

791833
def get_stretch(self):
792-
'Get the font stretch as a string or number'
834+
"""
835+
Get the font stretch as a string or number
836+
837+
See Also
838+
--------
839+
.font_manager.FontProperties.get_stretch
840+
"""
793841
return self._fontproperties.get_stretch()
794842

795843
def get_horizontalalignment(self):
@@ -844,7 +892,7 @@ def get_verticalalignment(self):
844892

845893
def get_window_extent(self, renderer=None, dpi=None):
846894
'''
847-
Return a :class:`~matplotlib.transforms.Bbox` object bounding
895+
Return a `~matplotlib.transforms.Bbox` object bounding
848896
the text, in display units.
849897
850898
In addition to being used internally, this is useful for
@@ -853,9 +901,9 @@ def get_window_extent(self, renderer=None, dpi=None):
853901
*renderer* defaults to the _renderer attribute of the text
854902
object. This is not assigned until the first execution of
855903
:meth:`draw`, so you must use this kwarg if you want
856-
to call :meth:`get_window_extent` prior to the first
857-
:meth:`draw`. For getting web page regions, it is
858-
simpler to call the method after saving the figure.
904+
to call `.get_window_extent` prior to the first `draw`. For
905+
getting web page regions, it is simpler to call the method after
906+
saving the figure.
859907
860908
*dpi* defaults to self.figure.dpi; the renderer dpi is
861909
irrelevant. For the web application, if figure.dpi is not
@@ -889,14 +937,13 @@ def set_backgroundcolor(self, color):
889937
"""
890938
Set the background color of the text by updating the bbox.
891939
892-
.. seealso::
893-
894-
:meth:`set_bbox`
895-
To change the position of the bounding box.
896-
897940
Parameters
898941
----------
899942
color : color
943+
944+
See Also
945+
--------
946+
.set_bbox : To change the position of the bounding box
900947
"""
901948
if self._bbox_patch is None:
902949
self.set_bbox(dict(facecolor=color, edgecolor=color))
@@ -946,7 +993,7 @@ def set_multialignment(self, align):
946993
947994
Parameters
948995
----------
949-
align: {'left', 'right', 'center'}
996+
align : {'left', 'right', 'center'}
950997
"""
951998
legal = ('center', 'right', 'left')
952999
if align not in legal:
@@ -978,6 +1025,10 @@ def set_fontfamily(self, fontname):
9781025
----------
9791026
fontname : {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', \
9801027
'monospace'}
1028+
1029+
See Also
1030+
--------
1031+
.font_manager.FontProperties.set_family
9811032
"""
9821033
self._fontproperties.set_family(fontname)
9831034
self.stale = True
@@ -989,6 +1040,10 @@ def set_fontvariant(self, variant):
9891040
Parameters
9901041
----------
9911042
variant : {'normal', 'small-caps'}
1043+
1044+
See Also
1045+
--------
1046+
.font_manager.FontProperties.set_variant
9921047
"""
9931048
self._fontproperties.set_variant(variant)
9941049
self.stale = True
@@ -1000,6 +1055,10 @@ def set_fontstyle(self, fontstyle):
10001055
Parameters
10011056
----------
10021057
fontstyle : {'normal', 'italic', 'oblique'}
1058+
1059+
See Also
1060+
--------
1061+
.font_manager.FontProperties.set_style
10031062
"""
10041063
self._fontproperties.set_style(fontstyle)
10051064
self.stale = True
@@ -1013,6 +1072,10 @@ def set_fontsize(self, fontsize):
10131072
----------
10141073
fontsize : {size in points, 'xx-small', 'x-small', 'small', 'medium', \
10151074
'large', 'x-large', 'xx-large'}
1075+
1076+
See Also
1077+
--------
1078+
.font_manager.FontProperties.set_size
10161079
"""
10171080
self._fontproperties.set_size(fontsize)
10181081
self.stale = True
@@ -1026,6 +1089,10 @@ def set_fontweight(self, weight):
10261089
weight : {a numeric value in range 0-1000, 'ultralight', 'light', \
10271090
'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', \
10281091
'demi', 'bold', 'heavy', 'extra bold', 'black'}
1092+
1093+
See Also
1094+
--------
1095+
.font_manager.FontProperties.set_weight
10291096
"""
10301097
self._fontproperties.set_weight(weight)
10311098
self.stale = True
@@ -1039,6 +1106,10 @@ def set_fontstretch(self, stretch):
10391106
stretch : {a numeric value in range 0-1000, 'ultra-condensed', \
10401107
'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', \
10411108
'expanded', 'extra-expanded', 'ultra-expanded'}
1109+
1110+
See Also
1111+
--------
1112+
.font_manager.FontProperties.set_stretch
10421113
"""
10431114
self._fontproperties.set_stretch(stretch)
10441115
self.stale = True
@@ -1144,12 +1215,11 @@ def is_math_text(s, usetex=None):
11441215

11451216
def set_fontproperties(self, fp):
11461217
"""
1147-
Set the font properties that control the text. *fp* must be a
1148-
:class:`matplotlib.font_manager.FontProperties` object.
1218+
Set the font properties that control the text.
11491219
11501220
Parameters
11511221
----------
1152-
fp : matplotlib.font_manager.FontProperties
1222+
fp : `.font_manager.FontProperties`
11531223
"""
11541224
if isinstance(fp, str):
11551225
fp = FontProperties(fp)
@@ -1184,9 +1254,19 @@ def get_usetex(self):
11841254

11851255
def set_fontname(self, fontname):
11861256
"""
1187-
alias for set_family
1257+
alias for `.set_family`
11881258
11891259
One-way alias only: the getter differs.
1260+
1261+
Parameters
1262+
----------
1263+
fontname : {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', \
1264+
'monospace'}
1265+
1266+
See Also
1267+
--------
1268+
.font_manager.FontProperties.set_family
1269+
11901270
"""
11911271
return self.set_family(fontname)
11921272

0 commit comments

Comments
 (0)