From fa186cfc03c69c8dc1c7ec60bad89db621d35814 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Fri, 1 Mar 2013 17:19:27 +0100 Subject: [PATCH] MEP10 - documentation improvements on set_xlabel and text of axes.py --- lib/matplotlib/axes.py | 106 +++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index d80d5459da76..8d715cbc1b8d 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -3244,23 +3244,23 @@ def get_xlabel(self): @docstring.dedent_interpd def set_xlabel(self, xlabel, fontdict=None, labelpad=None, **kwargs): """ - Call signature:: - - set_xlabel(xlabel, fontdict=None, labelpad=None, **kwargs) - Set the label for the xaxis. - *labelpad* is the spacing in points between the label and the x-axis - - Valid kwargs are :class:`~matplotlib.text.Text` properties: - %(Text)s + Parameters + ---------- + xlabel : string + x label - ACCEPTS: str + labelpad : scalar, optional, default: None + spacing in points between the label and the x-axis - .. seealso:: + Other parameters + ---------------- + kwargs : `~matplotlib.text.Text` properties - :meth:`text` - for information on how override and the optional args work + See also + -------- + text : for information on how override and the optional args work """ if labelpad is not None: self.xaxis.labelpad = labelpad @@ -3276,23 +3276,24 @@ def get_ylabel(self): @docstring.dedent_interpd def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs): """ - Call signature:: - - set_ylabel(ylabel, fontdict=None, labelpad=None, **kwargs) - Set the label for the yaxis - *labelpad* is the spacing in points between the label and the y-axis + Parameters + ---------- + ylabel : string + y label - Valid kwargs are :class:`~matplotlib.text.Text` properties: - %(Text)s + labelpad : scalar, optional, default: None + spacing in points between the label and the x-axis - ACCEPTS: str + Other parameters + ---------------- + kwargs : `~matplotlib.text.Text` properties - .. seealso:: + See also + -------- + text : for information on how override and the optional args work - :meth:`text` - for information on how override and the optional args work """ if labelpad is not None: self.yaxis.labelpad = labelpad @@ -3304,49 +3305,52 @@ def text(self, x, y, s, fontdict=None, """ Add text to the axes. - Call signature:: - - text(x, y, s, fontdict=None, **kwargs) - Add text in string *s* to axis at location *x*, *y*, data coordinates. - Keyword arguments: + Parameters + ----------- + s : string + text - *fontdict*: - A dictionary to override the default text properties. - If *fontdict* is *None*, the defaults are determined by your rc - parameters. + x, y : scalars + data coordinates - *withdash*: [ *False* | *True* ] - Creates a :class:`~matplotlib.text.TextWithDash` instance - instead of a :class:`~matplotlib.text.Text` instance. + fontdict : dictionary, optional, default: None + A dictionary to override the default text properties. If fontdict + is None, the defaults are determined by your rc parameters. + withdash : boolean, optional, default: False + Creates a `~matplotlib.text.TextWithDash` instance instead of a + `~matplotlib.text.Text` instance. + + Other parameters + ---------------- + kwargs : `~matplotlib.text.Text` properties. + + Examples + -------- Individual keyword arguments can be used to override any given parameter:: - text(x, y, s, fontsize=12) + >>> text(x, y, s, fontsize=12) The default transform specifies that text is in data coords, alternatively, you can specify text in axis coords (0,0 is lower-left and 1,1 is upper-right). The example below places text in the center of the axes:: - text(0.5, 0.5,'matplotlib', - horizontalalignment='center', - verticalalignment='center', - transform = ax.transAxes) - - You can put a rectangular box around the text instance (eg. to - set a background color) by using the keyword *bbox*. *bbox* is - a dictionary of :class:`matplotlib.patches.Rectangle` - properties. For example:: + >>> text(0.5, 0.5,'matplotlib', horizontalalignment='center', + >>> verticalalignment='center', + >>> transform = ax.transAxes) - text(x, y, s, bbox=dict(facecolor='red', alpha=0.5)) + You can put a rectangular box around the text instance (eg. to + set a background color) by using the keyword *bbox*. *bbox* is + a dictionary of `~matplotlib.patches.Rectangle` + properties. For example:: - Valid kwargs are :class:`~matplotlib.text.Text` properties: + >>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5)) - %(Text)s """ default = { 'verticalalignment': 'baseline', @@ -3362,12 +3366,10 @@ def text(self, x, y, s, fontdict=None, # a dash to TextWithDash and dashlength. if withdash: t = mtext.TextWithDash( - x=x, y=y, text=s, - ) + x=x, y=y, text=s) else: t = mtext.Text( - x=x, y=y, text=s, - ) + x=x, y=y, text=s) self._set_artist_props(t) t.update(default)