Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 71af83c

Browse filesBrowse files
committed
Merge pull request #1804 from NelleV/MEP10_xy_labels
MEP10 - documentation improvements on set_xlabel and text of axes.py
2 parents dffac7a + fa186cf commit 71af83c
Copy full SHA for 71af83c

File tree

Expand file treeCollapse file tree

1 file changed

+54
-52
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+54
-52
lines changed

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+54-52Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3244,23 +3244,23 @@ def get_xlabel(self):
32443244
@docstring.dedent_interpd
32453245
def set_xlabel(self, xlabel, fontdict=None, labelpad=None, **kwargs):
32463246
"""
3247-
Call signature::
3248-
3249-
set_xlabel(xlabel, fontdict=None, labelpad=None, **kwargs)
3250-
32513247
Set the label for the xaxis.
32523248
3253-
*labelpad* is the spacing in points between the label and the x-axis
3254-
3255-
Valid kwargs are :class:`~matplotlib.text.Text` properties:
3256-
%(Text)s
3249+
Parameters
3250+
----------
3251+
xlabel : string
3252+
x label
32573253
3258-
ACCEPTS: str
3254+
labelpad : scalar, optional, default: None
3255+
spacing in points between the label and the x-axis
32593256
3260-
.. seealso::
3257+
Other parameters
3258+
----------------
3259+
kwargs : `~matplotlib.text.Text` properties
32613260
3262-
:meth:`text`
3263-
for information on how override and the optional args work
3261+
See also
3262+
--------
3263+
text : for information on how override and the optional args work
32643264
"""
32653265
if labelpad is not None:
32663266
self.xaxis.labelpad = labelpad
@@ -3276,23 +3276,24 @@ def get_ylabel(self):
32763276
@docstring.dedent_interpd
32773277
def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs):
32783278
"""
3279-
Call signature::
3280-
3281-
set_ylabel(ylabel, fontdict=None, labelpad=None, **kwargs)
3282-
32833279
Set the label for the yaxis
32843280
3285-
*labelpad* is the spacing in points between the label and the y-axis
3281+
Parameters
3282+
----------
3283+
ylabel : string
3284+
y label
32863285
3287-
Valid kwargs are :class:`~matplotlib.text.Text` properties:
3288-
%(Text)s
3286+
labelpad : scalar, optional, default: None
3287+
spacing in points between the label and the x-axis
32893288
3290-
ACCEPTS: str
3289+
Other parameters
3290+
----------------
3291+
kwargs : `~matplotlib.text.Text` properties
32913292
3292-
.. seealso::
3293+
See also
3294+
--------
3295+
text : for information on how override and the optional args work
32933296
3294-
:meth:`text`
3295-
for information on how override and the optional args work
32963297
"""
32973298
if labelpad is not None:
32983299
self.yaxis.labelpad = labelpad
@@ -3304,49 +3305,52 @@ def text(self, x, y, s, fontdict=None,
33043305
"""
33053306
Add text to the axes.
33063307
3307-
Call signature::
3308-
3309-
text(x, y, s, fontdict=None, **kwargs)
3310-
33113308
Add text in string *s* to axis at location *x*, *y*, data
33123309
coordinates.
33133310
3314-
Keyword arguments:
3311+
Parameters
3312+
-----------
3313+
s : string
3314+
text
33153315
3316-
*fontdict*:
3317-
A dictionary to override the default text properties.
3318-
If *fontdict* is *None*, the defaults are determined by your rc
3319-
parameters.
3316+
x, y : scalars
3317+
data coordinates
33203318
3321-
*withdash*: [ *False* | *True* ]
3322-
Creates a :class:`~matplotlib.text.TextWithDash` instance
3323-
instead of a :class:`~matplotlib.text.Text` instance.
3319+
fontdict : dictionary, optional, default: None
3320+
A dictionary to override the default text properties. If fontdict
3321+
is None, the defaults are determined by your rc parameters.
33243322
3323+
withdash : boolean, optional, default: False
3324+
Creates a `~matplotlib.text.TextWithDash` instance instead of a
3325+
`~matplotlib.text.Text` instance.
3326+
3327+
Other parameters
3328+
----------------
3329+
kwargs : `~matplotlib.text.Text` properties.
3330+
3331+
Examples
3332+
--------
33253333
Individual keyword arguments can be used to override any given
33263334
parameter::
33273335
3328-
text(x, y, s, fontsize=12)
3336+
>>> text(x, y, s, fontsize=12)
33293337
33303338
The default transform specifies that text is in data coords,
33313339
alternatively, you can specify text in axis coords (0,0 is
33323340
lower-left and 1,1 is upper-right). The example below places
33333341
text in the center of the axes::
33343342
3335-
text(0.5, 0.5,'matplotlib',
3336-
horizontalalignment='center',
3337-
verticalalignment='center',
3338-
transform = ax.transAxes)
3339-
3340-
You can put a rectangular box around the text instance (eg. to
3341-
set a background color) by using the keyword *bbox*. *bbox* is
3342-
a dictionary of :class:`matplotlib.patches.Rectangle`
3343-
properties. For example::
3343+
>>> text(0.5, 0.5,'matplotlib', horizontalalignment='center',
3344+
>>> verticalalignment='center',
3345+
>>> transform = ax.transAxes)
33443346
3345-
text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
3347+
You can put a rectangular box around the text instance (eg. to
3348+
set a background color) by using the keyword *bbox*. *bbox* is
3349+
a dictionary of `~matplotlib.patches.Rectangle`
3350+
properties. For example::
33463351
3347-
Valid kwargs are :class:`~matplotlib.text.Text` properties:
3352+
>>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))
33483353
3349-
%(Text)s
33503354
"""
33513355
default = {
33523356
'verticalalignment': 'baseline',
@@ -3362,12 +3366,10 @@ def text(self, x, y, s, fontdict=None,
33623366
# a dash to TextWithDash and dashlength.
33633367
if withdash:
33643368
t = mtext.TextWithDash(
3365-
x=x, y=y, text=s,
3366-
)
3369+
x=x, y=y, text=s)
33673370
else:
33683371
t = mtext.Text(
3369-
x=x, y=y, text=s,
3370-
)
3372+
x=x, y=y, text=s)
33713373
self._set_artist_props(t)
33723374

33733375
t.update(default)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.