From: <md...@us...> - 2008-06-19 13:16:39
|
Revision: 5593 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5593&view=rev Author: mdboom Date: 2008-06-19 06:16:16 -0700 (Thu, 19 Jun 2008) Log Message: ----------- Lots of docstring formatting fixes. Modified Paths: -------------- trunk/matplotlib/doc/faq/installing_faq.rst trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/artist.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/pyplot.py trunk/matplotlib/lib/matplotlib/quiver.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/doc/faq/installing_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/installing_faq.rst 2008-06-19 12:16:50 UTC (rev 5592) +++ trunk/matplotlib/doc/faq/installing_faq.rst 2008-06-19 13:16:16 UTC (rev 5593) @@ -55,8 +55,8 @@ easy_install -m PackageName -3. Delete any .egg files or directories from your `installation directory - <locating-matplotlib-install>`. +3. Delete any .egg files or directories from your :ref:`installation + directory <locating-matplotlib-install>`. Windows installer Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-19 12:16:50 UTC (rev 5592) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-19 13:16:16 UTC (rev 5593) @@ -684,11 +684,11 @@ def rc(group, **kwargs): """ - Set the current rc params. Group is the grouping for the rc, eg - for lines.linewidth the group is 'lines', for axes.facecolor, the - group is 'axes', and so on. Group may also be a list or tuple - of group names, eg ('xtick','ytick'). kwargs is a list of - attribute name/value pairs, eg:: + Set the current rc params. Group is the grouping for the rc, eg. + for ``lines.linewidth`` the group is ``lines``, for + ``axes.facecolor``, the group is ``axes``, and so on. Group may + also be a list or tuple of group names, eg. (*xtick*, *ytick*). + *kwargs* is a dictionary attribute name/value pairs, eg:: rc('lines', linewidth=2, color='r') @@ -728,7 +728,8 @@ rc('font', **font) # pass in the font dict as kwargs This enables you to easily switch between several configurations. - Use rcdefaults to restore the default rc params after changes. + Use :func:`~matplotlib.pyplot.rcdefaults` to restore the default + rc params after changes. """ aliases = { @@ -756,7 +757,7 @@ def rcdefaults(): """ Restore the default rc params - the ones that were created at - matplotlib load time + matplotlib load time. """ rcParams.update(rcParamsDefault) Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2008-06-19 12:16:50 UTC (rev 5592) +++ trunk/matplotlib/lib/matplotlib/artist.py 2008-06-19 13:16:16 UTC (rev 5593) @@ -707,31 +707,32 @@ def setp(h, *args, **kwargs): """ - matplotlib supports the use of setp ("set property") and getp to set - and get object properties, as well as to do introspection on the - object For example, to set the linestyle of a line to be dashed, you - can do + matplotlib supports the use of :func:`setp` ("set property") and + :func:`getp` to set and get object properties, as well as to do + introspection on the object. For example, to set the linestyle of a + line to be dashed, you can do:: >>> line, = plot([1,2,3]) >>> setp(line, linestyle='--') If you want to know the valid types of arguments, you can provide the - name of the property you want to set without a value + name of the property you want to set without a value:: >>> setp(line, 'linestyle') linestyle: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' ] If you want to see all the properties that can be set, and their - possible values, you can do + possible values, you can do:: >>> setp(line) ... long output listing omitted - setp operates on a single instance or a list of instances. If you - are in query mode introspecting the possible values, only the first - instance in the sequence is used. When actually setting values, - all the instances will be set. Eg, suppose you have a list of two - lines, the following will make both lines thicker and red + :func:`setp` operates on a single instance or a list of instances. + If you are in query mode introspecting the possible values, only + the first instance in the sequence is used. When actually setting + values, all the instances will be set. Eg., suppose you have a + list of two lines, the following will make both lines thicker and + red:: >>> x = arange(0,1.0,0.01) >>> y1 = sin(2*pi*x) @@ -739,8 +740,8 @@ >>> lines = plot(x, y1, x, y2) >>> setp(lines, linewidth=2, color='r') - setp works with the matlab(TM) style string/value pairs or with - python kwargs. For example, the following are equivalent + :func:`setp` works with the matlab(TM) style string/value pairs or + with python kwargs. For example, the following are equivalent >>> setp(lines, 'linewidth', 2, 'color', r') # matlab style >>> setp(lines, linewidth=2, color='r') # python style Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-19 12:16:50 UTC (rev 5592) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-19 13:16:16 UTC (rev 5593) @@ -1546,17 +1546,18 @@ grid(self, b=None, **kwargs) - Set the axes grids on or off; b is a boolean + Set the axes grids on or off; *b* is a boolean - if b is None and len(kwargs)==0, toggle the grid state. if - kwargs are supplied, it is assumed that you want a grid and b - is thus set to True + If *b* is *None* and len(kwargs)==0, toggle the grid state. If + kwargs are supplied, it is assumed that you want a grid and *b* + is thus set to *True* kawrgs are used to set the grid line properties, eg:: ax.grid(color='r', linestyle='-', linewidth=2) - Valid Line2D kwargs are + Valid :class:`~matplotlib.lines.Line2D` kwargs are + %(Line2D)s """ if len(kwargs): b = True @@ -2457,40 +2458,44 @@ text(x, y, s, fontdict=None, **kwargs) - Add text in string s to axis at location x,y (data coords) + Add text in string *s* to axis at location *x*, *y*, data + coordinates. Keyword arguments: - fontdict: - a dictionary to override the default text properties. - If fontdict is None, the defaults are determined by your rc + *fontdict*: + A dictionary to override the default text properties. + If *fontdict* is *None*, the defaults are determined by your rc parameters. - withdash: [ False | True ] - creates a TextWithDash instance instead of a Text instance. + *withdash*: [ False | True ] + Creates a :class:`~matplotlib.text.TextWithDash` instance + instead of a :class:`~matplotlib.text.Text` instance. + Individual keyword arguments can be used to override any given parameter:: 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 lower left and - 1,1 upper right). The example below places text in the center of the - axes:: + 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 patches.Rectangle properties (see help - for Rectangle for a list of these). For example:: + 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(x, y, s, bbox=dict(facecolor='red', alpha=0.5)) - Valid kwargs are Text properties + Valid kwargs are :class:`matplotlib.text.Text` properties: + %(Text)s """ default = { @@ -2536,6 +2541,7 @@ textcoords='data', arrowprops=None, **kwargs) Keyword arguments: + %(Annotation)s """ a = mtext.Annotation(*args, **kwargs) @@ -2556,30 +2562,33 @@ Axis Horizontal Line - Draw a horizontal line at y from xmin to xmax. With the default - values of xmin=0 and xmax=1, this line will always span the horizontal - extent of the axes, regardless of the xlim settings, even if you - change them, eg with the xlim command. That is, the horizontal extent - is in axes coords: 0=left, 0.5=middle, 1.0=right but the y location is - in data coordinates. + Draw a horizontal line at *y* from *xmin* to *xmax*. With the + default values of *xmin* = 0 and *xmax* = 1, this line will + always span the horizontal extent of the axes, regardless of + the xlim settings, even if you change them, eg. with the + :meth:`set_xlim` command. That is, the horizontal extent is + in axes coords: 0=left, 0.5=middle, 1.0=right but the *y* + location is in data coordinates. - Return value is the Line2D instance. kwargs are the same as kwargs to - plot, and can be used to control the line properties. Eg + Return value is the :class:`~matplotlib.lines.Line2D` + instance. kwargs are the same as kwargs to plot, and can be + used to control the line properties. Eg., - * draw a thick red hline at y=0 that spans the xrange + * draw a thick red hline at *y* = 0 that spans the xrange >>> axhline(linewidth=4, color='r') - * draw a default hline at y=1 that spans the xrange + * draw a default hline at *y* = 1 that spans the xrange >>> axhline(y=1) - * draw a default hline at y=.5 that spans the the middle half of + * draw a default hline at *y* = .5 that spans the the middle half of the xrange >>> axhline(y=.5, xmin=0.25, xmax=0.75) - Valid kwargs are Line2D properties + Valid kwargs are :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ @@ -2603,30 +2612,33 @@ Axis Vertical Line - Draw a vertical line at x from ymin to ymax. With the default values - of ymin=0 and ymax=1, this line will always span the vertical extent - of the axes, regardless of the xlim settings, even if you change them, - eg with the xlim command. That is, the vertical extent is in axes - coords: 0=bottom, 0.5=middle, 1.0=top but the x location is in data - coordinates. + Draw a vertical line at *x* from *ymin* to *ymax*. With the + default values of *ymin* = 0 and *ymax* = 1, this line will + always span the vertical extent of the axes, regardless of the + xlim settings, even if you change them, eg. with the + :meth:`set_xlim` command. That is, the vertical extent is in + axes coords: 0=bottom, 0.5=middle, 1.0=top but the *x* location + is in data coordinates. - Return value is the Line2D instance. kwargs are the same as - kwargs to plot, and can be used to control the line properties. Eg + Return value is the :class:`~matplotlib.lines.Line2D` + instance. kwargs are the same as kwargs to plot, and can be + used to control the line properties. Eg., - * draw a thick red vline at x=0 that spans the yrange + * draw a thick red vline at *x* = 0 that spans the yrange >>> axvline(linewidth=4, color='r') - * draw a default vline at x=1 that spans the yrange + * draw a default vline at *x* = 1 that spans the yrange >>> axvline(x=1) - * draw a default vline at x=.5 that spans the the middle half of + * draw a default vline at *x* = .5 that spans the the middle half of the yrange >>> axvline(x=.5, ymin=0.25, ymax=0.75) - Valid kwargs are Line2D properties + Valid kwargs are :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ @@ -2648,26 +2660,31 @@ axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs) - Axis Horizontal Span. ycoords are in data units and x - coords are in axes (relative 0-1) units + Axis Horizontal Span. - Draw a horizontal span (regtangle) from ymin to ymax. With the - default values of xmin=0 and xmax=1, this always span the xrange, - regardless of the xlim settings, even if you change them, eg with the - xlim command. That is, the horizontal extent is in axes coords: - 0=left, 0.5=middle, 1.0=right but the y location is in data + *y* coords are in data units and *x* coords are in axes (relative + 0-1) units. + + Draw a horizontal span (rectangle) from *ymin* to *ymax*. + With the default values of *xmin* = 0 and *xmax* = 1, this + always span the xrange, regardless of the xlim settings, even + if you change them, eg. with the :meth:`set_xlim` command. + That is, the horizontal extent is in axes coords: 0=left, + 0.5=middle, 1.0=right but the *y* location is in data coordinates. - Return value is the patches.Polygon instance. + Return value is a :class:`matplotlib.patches.Polygon` + instance. Examples: - * draw a gray rectangle from y=0.25-0.75 that spans the horizontal - extent of the axes + * draw a gray rectangle from *y* = 0.25-0.75 that spans the + horizontal extent of the axes >>> axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) - Valid kwargs are Polygon properties + Valid kwargs are :class:`~matplotlib.patches.Polygon` properties: + %(Polygon)s """ # convert y axis units @@ -2686,17 +2703,21 @@ axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs) - Axis Vertical Span. xcoords are in data units and y coords - are in axes (relative 0-1) units + Axis Vertical Span. - Draw a vertical span (regtangle) from xmin to xmax. With the default - values of ymin=0 and ymax=1, this always span the yrange, regardless - of the ylim settings, even if you change them, eg with the ylim - command. That is, the vertical extent is in axes coords: 0=bottom, - 0.5=middle, 1.0=top but the y location is in data coordinates. + *x* coords are in data units and *y* coords are in axes (relative + 0-1) units. - return value is the patches.Polygon instance. + Draw a vertical span (rectangle) from *xmin* to *xmax*. With + the default values of *ymin* = 0 and *ymax* = 1, this always + span the yrange, regardless of the ylim settings, even if you + change them, eg. with the :meth:`set_ylim` command. That is, + the vertical extent is in axes coords: 0=bottom, 0.5=middle, + 1.0=top but the *y* location is in data coordinates. + Return value is the :class:`matplotlib.patches.Polygon` + instance. + Examples: * draw a vertical green translucent rectangle from x=1.25 to 1.55 that @@ -2704,7 +2725,9 @@ >>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5) - Valid kwargs are Polygon properties: + Valid kwargs are :class:`~matplotlib.patches.Polygon` + properties: + %(Polygon)s """ # convert x axis units @@ -2725,27 +2748,28 @@ hlines(y, xmin, xmax, colors='k', linestyle='solid', **kwargs) - plot horizontal lines at each y from xmin to xmax. + Plot horizontal lines at each *y* from *xmin* to *xmax*. - Returns the LineCollection that was added + Returns the :class:`~matplotlib.collections.LineCollection` + that was added. Required arguments: - y: + *y*: a 1-D numpy array or iterable. - xmin and xmax: - can be scalars or len(x) numpy arrays. If they are scalars, then - the respective values are constant, else the widths of the lines - are determined by xmin and xmax + *xmin* and *xmax*: + can be scalars or ``len(x)`` numpy arrays. If they are + scalars, then the respective values are constant, else the + widths of the lines are determined by *xmin* and *xmax*. Optional keyword arguments: - colors: + *colors*: a line collections color argument, either a single color - or a len(y) list of colors + or a ``len(y)`` list of colors - linestyle: + *linestyle*: [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] """ @@ -2800,20 +2824,21 @@ vlines(x, ymin, ymax, color='k') - Plot vertical lines at each x from ymin to ymax. ymin or ymax can be - scalars or len(x) numpy arrays. If they are scalars, then the - respective values are constant, else the heights of the lines are - determined by ymin and ymax + Plot vertical lines at each *x* from *ymin* to *ymax*. *ymin* + or *ymax* can be scalars or len(*x*) numpy arrays. If they are + scalars, then the respective values are constant, else the + heights of the lines are determined by *ymin* and *ymax*. + *colors* is a line collections color args, either a single color + or a len(*x*) list of colors - colors is a line collections color args, either a single color - or a len(x) list of colors + *linestyle* is one of [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] - linestyle is one of [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] + Returns the :class:`matplotlib.collections.LineCollection` + that was added. - Returns the collections.LineCollection that was added + kwargs are :class:`~matplotlib.collections.LineCollection` properties: - kwargs are collections.LineCollection properties: %(LineCollection)s """ @@ -2870,19 +2895,22 @@ #### Basic plotting def plot(self, *args, **kwargs): """ - Plot lines and/or markers to the Axes. ``*args`` is a variable length - argument, allowing for multiple *x*, *y* pairs with an optional format - string. For example, each of the following is legal:: + Plot lines and/or markers to the + :class:`~matplotlib.axes.Axes`. *args* is a variable length + argument, allowing for multiple *x*, *y* pairs with an + optional format string. For example, each of the following is + legal:: plot(x, y) # plot x and y using the default line style and color plot(x, y, 'bo') # plot x and y using blue circle markers plot(y) # plot y using x as index array 0..N-1 plot(y, 'r+') # ditto, but with red plusses - If ``x`` and/or ``y`` is 2-dimensional, then the corresponding columns + If *x* and/or *y* is 2-dimensional, then the corresponding columns will be plotted. - An arbitrary number of ``x``, ``y``, ``fmt`` groups can be specified, as in:: + An arbitrary number of *x*, *y*, *fmt* groups can be + specified, as in:: a.plot(x1, y1, 'g^', x2, y2, 'g-') @@ -2929,16 +2957,16 @@ w # white In addition, you can specify colors in many weird and - wonderful ways, including full names (``'green'``), hex strings - (``'#008000'``), RGB or RGBA tuples (``(0,1,0,1)``) or grayscale - intensities as a string (``'0.8'``). Of these, the string - specifications can be used in place of a ``fmt`` group, but the - tuple forms can be used only as ``kwargs``. + wonderful ways, including full names (``'green'``), hex + strings (``'#008000'``), RGB or RGBA tuples (``(0,1,0,1)``) or + grayscale intensities as a string (``'0.8'``). Of these, the + string specifications can be used in place of a ``fmt`` group, + but the tuple forms can be used only as ``kwargs``. Line styles and colors are combined in a single format string, as in ``'bo'`` for blue circles. - The ``**kwargs`` can be used to set line properties (any property that has + The *kwargs* can be used to set line properties (any property that has a ``set_*`` method). You can use this to set a line label (for auto legends), linewidth, anitialising, marker face color, etc. Here is an example:: @@ -2948,19 +2976,21 @@ axis([0, 4, 0, 10]) legend() - If you make multiple lines with one plot command, the ``kwargs`` apply - to all those lines, e.g.:: + If you make multiple lines with one plot command, the kwargs + apply to all those lines, e.g.:: plot(x1, y1, x2, y2, antialised=False) Neither line will be antialiased. - The kwargs are Line2D properties: + The kwargs are :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s - kwargs ``scalex`` and ``scaley``, if defined, are passed on to - :meth:`autoscale_view` to determine whether the *x* and *y* axes - are autoscaled; the default is ``True``. + kwargs *scalex* and *scaley*, if defined, are passed on to + :meth:`~matplotlib.axes.Axes.autoscale_view` to determine + whether the *x* and *y* axes are autoscaled; the default is + *True*. """ scalex = kwargs.pop( 'scalex', True) scaley = kwargs.pop( 'scaley', True) @@ -2985,36 +3015,48 @@ plot_date(x, y, fmt='bo', tz=None, xdate=True, ydate=False, **kwargs) - Similar to the plot() command, except the x or y (or both) data - is considered to be dates, and the axis is labeled accordingly. + Similar to the :func:`~matplotlib.pyplot.plot` command, except + the *x* or *y* (or both) data is considered to be dates, and the + axis is labeled accordingly. - x and/or y can be a sequence of dates represented as float days since + *x* and/or *y* can be a sequence of dates represented as float days since 0001-01-01 UTC. - See dates for helper functions date2num, num2date - and drange for help on creating the required floating point dates + See :mod:`~matplotlib.dates` for helper functions + :func:`~matplotlib.dates.date2num`, + :func:`~matplotlib.dates.num2date` and + :func:`~matplotlib.dates.drange` for help on creating the + required floating point dates. Keyword arguments: - fmt: string + *fmt*: string The plot format string. - tz: [ None | timezone string ] - The time zone to use in labeling dates. If None, defaults to rc + + *tz*: [ None | timezone string ] + The time zone to use in labeling dates. If *None*, defaults to rc value. - xdate: [ True | False ] - If True, the x-axis will be labeled with dates. - ydate: [ False | True ] - If True, the y-axis will be labeled with dates. + *xdate*: [ True | False ] + If *True*, the *x*-axis will be labeled with dates. + + *ydate*: [ False | True ] + If *True*, the *y*-axis will be labeled with dates. + Note if you are using custom date tickers and formatters, it may be necessary to set the formatters/locators after the call - to plot_date since plot_date will set the default tick locator - to ticker.AutoDateLocator (if the tick locator is not already set to - a ticker.DateLocator instance) and the default tick formatter to - AutoDateFormatter (if the tick formatter is not already set to - a DateFormatter instance). + to :meth:`plot_date` since :meth:`plot_date` will set the + default tick locator to + :class:`matplotlib.ticker.AutoDateLocator` (if the tick + locator is not already set to a + :class:`matplotlib.ticker.DateLocator` instance) and the + default tick formatter to + :class:`matplotlib.ticker.AutoDateFormatter` (if the tick + formatter is not already set to a + :class:`matplotlib.ticker.DateFormatter` instance). - Valid kwargs are Line2D properties: + Valid kwargs are :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ @@ -3040,22 +3082,27 @@ loglog(*args, **kwargs) - Make a plot with log scaling on the x and y axis. The args to loglog - are the same as the args to plot. See plot for more info. + Make a plot with log scaling on the *x* and *y* axis. - loglog supports all the keyword arguments of plot and - Axes.set_xscale/Axes.set_yscale. + :func:`~matplotlib.pyplot.loglog` supports all the keyword + arguments of :func:`~matplotlib.pyplot.plot` and + :meth:`matplotlib.axes.Axes.set_xscale`/:meth:`matplotlib.axes.Axes.set_yscale`. Notable keyword arguments: - basex/basey: scalar > 1 - base of the x/y logarithm - subsx/subsy: [ None | sequence ] - the location of the minor x/yticks; None defaults to - autosubs, which depend on the number of decades in the - plot; see set_xscale/set_yscale for details + *basex*/*basey*: scalar > 1 + base of the *x*/*y* logarithm - The remaining valid kwargs are Line2D properties: + *subsx*/*subsy*: [ None | sequence ] + the location of the minor *x*/*y* ticks; *None* defaults + to autosubs, which depend on the number of decades in the + plot; see + :meth:`matplotlib.axes.Axes.set_xscale`/:meth:`matplotlib.axes.Axes.set_yscale` + for details + + The remaining valid kwargs are + :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ if not self._hold: self.cla() @@ -3084,23 +3131,26 @@ semilogx(*args, **kwargs) - Make a plot with log scaling on the x axis. The args to - semilogx are the same as the args to plot. See plot for - more info. + Make a plot with log scaling on the *x* axis. - semilogx supports all the keyword arguments of plot and - Axes.set_xscale. + :func:`semilogx` supports all the keyword arguments of + :func:`~matplotlib.pyplot.plot` and + :meth:`matplotlib.axes.Axes.set_xscale`. Notable keyword arguments: - basex: scalar > 1 - base of the x logarithm - subsx: [ None | sequence ] - the location of the minor xticks; None defaults to + *basex*: scalar > 1 + base of the *x* logarithm + + *subsx*: [ None | sequence ] + The location of the minor xticks; *None* defaults to autosubs, which depend on the number of decades in the - plot; see set_xscale for details + plot; see :meth:`~matplotlib.axes.Axes.set_xscale` for + details. - The remaining valid kwargs are Line2D properties: + The remaining valid kwargs are + :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ if not self._hold: self.cla() @@ -3122,23 +3172,26 @@ semilogy(*args, **kwargs) - Make a plot with log scaling on the y axis. The args to - semilogy are the same as the args to plot. See plot for - more info. + Make a plot with log scaling on the *y* axis. - semilogy supports all the keyword arguments of plot and - Axes.set_yscale. + :func:`semilogy` supports all the keyword arguments of + :func:`~matplotlib.pylab.plot` and + :meth:`matplotlib.axes.Axes.set_yscale`. Notable keyword arguments: - basey: scalar > 1 - base of the y logarithm - subsy: [ None | sequence ] - the location of the minor yticks; None defaults to + *basey*: scalar > 1 + Base of the *y* logarithm + + *subsy*: [ None | sequence ] + The location of the minor yticks; *None* defaults to autosubs, which depend on the number of decades in the - plot; see set_yscale for details + plot; see :meth:`~matplotlib.axes.Axes.set_yscale` for + details. - The remaining valid kwargs are Line2D properties: + The remaining valid kwargs are + :class:`~matplotlib.lines.Line2D` properties: + %(Line2D)s """ if not self._hold: self.cla() @@ -3161,33 +3214,47 @@ acorr(x, normed=False, detrend=mlab.detrend_none, usevlines=False, maxlags=None, **kwargs) - Plot the autocorrelation of x. If normed=True, normalize the - data but the autocorrelation at 0-th lag. x is detrended by - the detrend callable (default no normalization. + Plot the autocorrelation of *x*. If *normed* = *True*, + normalize the data but the autocorrelation at 0-th lag. *x* is + detrended by the *detrend* callable (default no normalization). - data are plotted as ``plot(lags, c, **kwargs)`` + Data are plotted as ``plot(lags, c, **kwargs)`` - return value is lags, c, line where lags are a length - 2*maxlags+1 lag vector, c is the 2*maxlags+1 auto correlation - vector, and line is a Line2D instance returned by plot. The - default linestyle is None and the default marker is 'o', - though these can be overridden with keyword args. The cross - correlation is performed with numpy correlate with - mode=2. + Return value is a tuple (*lags*, *c*, *line*) where: - If usevlines is True, Axes.vlines rather than Axes.plot is used - to draw vertical lines from the origin to the acorr. - Otherwise the plotstyle is determined by the kwargs, which are - Line2D properties. If usevlines, the return value is lags, c, - linecol, b where linecol is the collections.LineCollection and b is the x-axis + - *lags* are a length 2*maxlags+1 lag vector - if usevlines=True, kwargs are passed onto Axes.vlines - if usevlines=False, kwargs are passed onto Axes.plot + - *c* is the 2*maxlags+1 auto correlation vector - maxlags is a positive integer detailing the number of lags to show. - The default value of None will return all (2*len(x)-1) lags. + - *line* is a :class:`~matplotlib.lines.Line2D` instance + returned by :meth:`plot` - See the respective function for documentation on valid kwargs + The default *linestyle* is None and the default *marker* is + ``'o'``, though these can be overridden with keyword args. + The cross correlation is performed with :func:`numpy.correlate` with + *mode* = 2. + + If *usevlines* is *True*: + + :meth:`~matplotlib.axes.Axes.vlines` rather than + :meth:`~matplotlib.axes.Axes.plot` is used to draw + vertical lines from the origin to the acorr. Otherwise, + the plot style is determined by the kwargs, which are + :class:`~matplotlib.lines.Line2D` properties. The return + value is a tuple (*lags*, *c*, *linecol*, *b*) where + + - *linecol* is the + :class:`~matplotlib.collections.LineCollection` + + - *b* is the *x*-axis. + + *maxlags* is a positive integer detailing the number of lags + to show. The default value of *None* will return all + ``(2*len(x)-1)`` lags. + + See the respective :meth:`~matplotlib.axes.Axes.plot` or + :meth:`~matplotlib.axes.Axes.vlines` functions for + documentation on valid kwargs. """ return self.xcorr(x, x, **kwargs) acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd @@ -3200,35 +3267,42 @@ xcorr(x, y, normed=False, detrend=mlab.detrend_none, usevlines=False, **kwargs): - Plot the cross correlation between x and y. If normed=True, - normalize the data but the cross correlation at 0-th lag. x - and y are detrended by the detrend callable (default no - normalization. x and y must be equal length + Plot the cross correlation between *x* and *y*. If *normed* = + *True*, normalize the data but the cross correlation at 0-th + lag. *x* and y are detrended by the *detrend* callable + (default no normalization). *x* and *y* must be equal length. - data are plotted as ``plot(lags, c, **kwargs)`` + Data are plotted as ``plot(lags, c, **kwargs)`` - return value is lags, c, line where lags are a length - ``2*maxlags+1`` lag vector, c is the ``2*maxlags+1`` auto correlation - vector, and line is a Line2D instance returned by plot. The - default linestyle is None and the default marker is 'o', - though these can be overridden with keyword args. The cross - correlation is performed with numpy correlate with - mode=2. + Return value is a tuple (*lags*, *c*, *line*) where: - If usevlines is True, Axes.vlines rather than Axes.plot is used - to draw vertical lines from the origin to the acorr. - Otherwise the plotstyle is determined by the kwargs, which are - Line2D properties. If usevlines, the return value is lags, c, - linecol, b where linecol is the collections.LineCollection and b is the - x-axis + - *lags* are a length ``2*maxlags+1`` lag vector - if ``usevlines=True``, kwargs are passed onto Axes.vlines - if ``usevlines=False``, kwargs are passed onto Axes.plot + - *c* is the ``2*maxlags+1`` auto correlation vector - maxlags is a positive integer detailing the number of lags to show. - The default value of None will return all ``(2*len(x)-1)`` lags. + - *line* is a :class:`~matplotlib.lines.Line2D` instance + returned by :func:`~matplotlib.pyplot.plot`. - See the respective function for documentation on valid kwargs + The default *linestyle* is *None* and the default *marker* is + 'o', though these can be overridden with keyword args. The + cross correlation is performed with :func:`numpy.correlate` + with *mode* = 2. + + If *usevlines* is *True*: + + :func:`~matplotlib.pyplot.vlines` + rather than :func:`~matplotlib.pyplot.plot` is used to draw + vertical lines from the origin to the xcorr. Otherwise the + plotstyle is determined by the kwargs, which are + :class:`~matplotlib.lines.Line2D` properties. + + The return value is a tuple (*lags*, *c*, *linecol*, *b*) + where *linecol* is the + :class:`matplotlib.collections.LineCollection` instance and + *b* is the *x*-axis. + + *maxlags* is a positive integer detailing the number of lags to show. + The default value of *None* will return all ``(2*len(x)-1)`` lags. """ Nx = len(x) @@ -3269,20 +3343,27 @@ legend(*args, **kwargs) - Place a legend on the current axes at location loc. Labels are a - sequence of strings and loc can be a string or an integer specifying - the legend location + Place a legend on the current axes at location *loc*. Labels are a + sequence of strings and *loc* can be a string or an integer specifying + the legend location. To make a legend with existing lines:: legend() - legend by itself will try and build a legend using the label + :meth:`legend` by itself will try and build a legend using the label property of the lines/patches/collections. You can set the label of - a line by doing plot(x, y, label='my data') or line.set_label('my - data'). If label is set to '_nolegend_', the item will not be shown - in legend. + a line by doing:: + plot(x, y, label='my data') + + or:: + + line.set_label('my data'). + + If label is set to '_nolegend_', the item will not be shown in + legend. + To automatically generate the legend from labels:: legend( ('label1', 'label2', 'label3') ) @@ -3325,32 +3406,41 @@ Keyword arguments: - isaxes: [ True | False ] + *isaxes*: [ True | False ] Indicates that this is an axes legend - numpoints: integer + + *numpoints*: integer The number of points in the legend line, default is 4 - prop: [ None | FontProperties ] - A FontProperties instance, or None to use rc settings. - see :class:`~matplotlib.font_manager.FontProperties` - pad: [ None | scalar ] + + *prop*: [ None | FontProperties ] + A :class:`matplotlib.font_manager.FontProperties` + instance, or *None* to use rc settings. + + *pad*: [ None | scalar ] The fractional whitespace inside the legend border, between 0 and 1. - If None, use rc settings - markerscale: [ None | scalar ] - The relative size of legend markers vs. original. If None, use rc - settings - shadow: [ None | False | True ] - If True, draw a shadow behind legend. If None, use rc settings. - labelsep: [ None | scalar ] - The vertical space between the legend entries. If None, use rc - settings - handlelen: [ None | scalar ] - The length of the legend lines. If None, use rc settings. - handletextsep: [ None | scalar ] - The space between the legend line and legend text. If None, use rc + If *None*, use rc settings. + + *markerscale*: [ None | scalar ] + The relative size of legend markers vs. original. If *None*, use rc settings. - axespad: [ None | scalar ] - The border between the axes and legend edge. If None, use rc + + *shadow*: [ None | False | True ] + If *True*, draw a shadow behind legend. If *None*, use rc settings. + + *labelsep*: [ None | scalar ] + The vertical space between the legend entries. If *None*, use rc settings. + + *handlelen*: [ None | scalar ] + The length of the legend lines. If *None*, use rc settings. + + *handletextsep*: [ None | scalar ] + The space between the legend line and legend text. If *None*, use rc + settings. + + *axespad*: [ None | scalar ] + The border between the axes and legend edge. If *None*, use rc + settings. """ def get_handles(): @@ -3409,21 +3499,21 @@ step(x, y, *args, **kwargs) - x and y must be 1-D sequences, and it is assumed, but not checked, - that x is uniformly increasing. + Make a step plot. Additional keyword args to :func:`step` are the same + as those for :func:`~matplotlib.pyplot.plot`. + *x* and *y* must be 1-D sequences, and it is assumed, but not checked, + that *x* is uniformly increasing. + Keyword arguments: - where: [ 'pre' | 'post' | 'mid' ] - if 'pre', the interval from x[i] to x[i+1] has level y[i] + *where*: [ 'pre' | 'post' | 'mid' ] + If 'pre', the interval from x[i] to x[i+1] has level y[i] - if 'post', that interval has level y[i+1] + If 'post', that interval has level y[i+1] - if 'mid', the jumps in y occur half-way between the x-values. - - Make a step plot. Additional keyword args to step are the same - as those for plot. See plot for more info. - + If 'mid', the jumps in *y* occur half-way between the + *x*-values. ''' where = kwargs.pop('where', 'pre') @@ -3450,12 +3540,14 @@ Make a bar plot with rectangles bounded by: - left, left+width, bottom, bottom+height + *left*, *left* + *width*, *bottom*, *bottom* + *height* (left, right, bottom and top edges) - left, height, width, and bottom can be either scalars or sequences + *left*, *height*, *width*, and *bottom* can be either scalars + or sequences - Return value is a list of Rectangle patch instances + Return value is a list of + :class:`matplotlib.patches.Rectangle` instances. Required arguments: @@ -3488,18 +3580,20 @@ axis as-is; True sets it to log scale ============= =================================================== - For vertical bars, align='edge' aligns bars by their left edges in - left, while 'center' interprets these values as the x coordinates of - the bar centers. For horizontal bars, 'edge' aligns bars by their - bottom edges in bottom, while 'center' interprets these values as the - y coordinates of the bar centers. + For vertical bars, *align* = 'edge' aligns bars by their left + edges in left, while *align* = 'center' interprets these + values as the *x* coordinates of the bar centers. For + horizontal bars, *align* = 'edge' aligns bars by their bottom + edges in bottom, while *align* = 'center' interprets these + values as the *y* coordinates of the bar centers. - The optional arguments color, edgecolor, linewidth, xerr, and yerr can - be either scalars or sequences of length equal to the number of bars. - This enables you to use bar as the basis for stacked bar charts, or - candlestick plots. + The optional arguments *color*, *edgecolor*, *linewidth*, + *xerr*, and *yerr* can be either scalars or sequences of + length equal to the number of bars. This enables you to use + bar as the basis for stacked bar charts, or candlestick plots. Other optional kwargs: + %(Rectangle)s """ if not self._hold: self.cla() @@ -3698,12 +3792,14 @@ Make a horizontal bar plot with rectangles bounded by: - left, left+width, bottom, bottom+height + *left*, *left* + *width*, *bottom*, *bottom* + *height* (left, right, bottom and top edges) - bottom, width, height, and left can be either scalars or sequences + *bottom*, *width*, *height*, and *left* can be either scalars + or sequences - Return value is a list of Rectangle patch instances + Return value is a list of + :class:`matplotlib.patches.Rectangle` instances. Required arguments: @@ -3735,16 +3831,18 @@ axis as-is; True sets it to log scale ============= =================================================== - Setting align='edge' aligns bars by their bottom edges in bottom, - while 'center' interprets these values as the y coordinates of the bar - centers. + Setting *align* = 'edge' aligns bars by their bottom edges in + bottom, while *align* = 'center' interprets these values as + the *y* coordinates of the bar centers. - The optional arguments color, edgecolor, linewidth, xerr, and yerr can - be either scalars or sequences of length equal to the number of bars. - This enables you to use barh as the basis for stacked bar charts, or - candlestick plots. + The optional arguments *color*, *edgecolor*, *linewidth*, + *xerr*, and *yerr* can be either scalars or sequences of + length equal to the number of bars. This enables you to use + barh as the basis for stacked bar charts, or candlestick + plots. other optional kwargs: + %(Rectangle)s """ @@ -3760,8 +3858,8 @@ broken_barh(self, xranges, yrange, **kwargs) - A collection of horizontal bars spanning yrange with a sequence of - xranges + A collection of horizontal bars spanning *yrange* with a sequence of + *xranges*. Required arguments: @@ -3772,7 +3870,10 @@ yrange sequence of (ymin, ywidth) ======== ========================== - kwargs are collections.BrokenBarHCollection properties: + kwargs are + :class:`matplotlib.collections.BrokenBarHCollection` + properties: + %(BrokenBarHCollection)s these can either be a single argument, ie:: @@ -3781,8 +3882,7 @@ or a sequence of arguments for the various bars, ie:: - facecolors = 'black', 'red', 'green' - + facecolors = ('black', 'red', 'green') """ col = mcoll.BrokenBarHCollection(xranges, yrange, **kwargs) self.add_collection(col, autolim=True) @@ -3798,15 +3898,17 @@ stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-') - A stem plot plots vertical lines (using linefmt) at each x location - from the baseline to y, and places a marker there using markerfmt. A - horizontal line at 0 is is plotted using basefmt + A stem plot plots vertical lines (using *linefmt*) at each *x* + location from the baseline to *y*, and places a marker there + using *markerfmt*. A horizontal line at 0 is is plotted using + *basefmt*. - Return value is (markerline, stemlines, baseline) . + Return value is a tuple (*markerline*, *stemlines*, + *baseline*). - See - http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html - for details and examples/stem_plot.py for a demo. + See `this document + <http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html>`_ + for details and :file:`examples/pylab_examples/stem_plot.py` for a demo. """ remember_hold=self._hold if not self._hold: self.cla() @@ -3829,56 +3931,68 @@ def pie(self, x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1): - """ + r""" call signature:: pie(x, explode=None, labels=None, colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'), autopct=None, pctdistance=0.6, labeldistance=1.1, shadow=False) - Make a pie chart of array x. The fractional area of each wedge is - given by x/sum(x). If sum(x)<=1, then the values of x give the - fractional area directly and the array will not be normalized. + Make a pie chart of array *x*. The fractional area of each + wedge is given by x/sum(x). If sum(x) <= 1, then the values + of x give the fractional area directly and the array will not + be normalized. Keyword arguments: - explode: [ None | len(x) sequence ] - If not None, is a len(x) array which specifies the + *explode*: [ None | len(x) sequence ] + If not *None*, is a len(*x*) array which specifies the fraction of the radius with which to offset each wedge. - colors: [ None | color sequence ] + + *colors*: [ None | color sequence ] A sequence of matplotlib color args through which the pie chart will cycle. - labels: [ None | len(x) sequence of strings ] + + *labels*: [ None | len(x) sequence of strings ] A sequence of strings providing the labels for each wedge - autopct: [ None | format string | format function ] - If not None, is a string or function used to label the + + *autopct*: [ None | format string | format function ] + If not *None*, is a string or function used to label the wedges with their numeric value. The label will be placed inside - the wedge. If it is a format string, the label will be fmt%pct. - If it is a function, it will be called - pctdistance: scalar - The ratio between the center of each pie slice and the start of the - text generated by autopct. Ignored if autopct is None; default is - 0.6. - labeldistance: scalar + the wedge. If it is a format string, the label will be ``fmt%pct``. + If it is a function, it will be called. + + *pctdistance*: scalar + The ratio between the center of each pie slice and the + start of the text generated by *autopct*. Ignored if + *autopct* is *None*; default is 0.6. + + *labeldistance*: scalar The radial distance at which the pie labels are drawn - shadow: [ False | True ] + + *shadow*: [ False | True ] Draw a shadow beneath the pie. The pie chart will probably look best if the figure and axes are - square. Eg:: + square. Eg.:: figure(figsize=(8,8)) ax = axes([0.1, 0.1, 0.8, 0.8]) Return value: - If autopct is None, return a list of (patches, texts), where patches - is a sequence of mpatches.Wedge instances and texts is a - list of the label Text instnaces + If *autopct* is None, return the tuple (*patches*, *texts*): - If autopct is not None, return (patches, texts, autotexts), where - patches and texts are as above, and autotexts is a list of text - instances for the numeric labels + - *patches* is a sequence of + :class:`matplotlib.patches.Wedge` instances + - *texts* is a list of the label + :class:`matplotlib.text.Text` instances. + + If *autopct* is not *None*, return the tuple (*patches*, + *texts*, *autotexts*), where *patches* and *texts* are as + above, and *autotexts* is a list of + :class:`~matplotlib.text.Text` instances for the numeric + labels. """ self.set_frame_on(False) @@ -3975,40 +4089,47 @@ barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False) - Plot x versus y with error deltas in yerr and xerr. - Vertical errorbars are plotted if yerr is not None. - Horizontal errorbars are plotted if xerr is not None. + Plot *x* versus *y* with error deltas in *yerr* and *xerr*. + Vertical errorbars are plotted if *yerr* is not *None*. + Horizontal errorbars are plotted if *xerr* is not *None*. - x, y, xerr, and yerr can all be scalars, which plots a single error bar - at x, y. + *x*, *y*, *xerr*, and *yerr* can all be scalars, which plots a + single error bar at *x*, *y*. Optional keyword arguments: - xerr/yerr: [ scalar | N, Nx1, Nx2 array-like ] + *xerr*/*yerr*: [ scalar | N, Nx1, Nx2 array-like ] If a scalar number, len(N) array-like object, or an Nx1 array-like object, errorbars are drawn +/- value. If a rank-1, Nx2 Numpy array, errorbars are drawn at -column1 and +column2 - fmt: '-' - The plot format symbol for y. If fmt is None, just plot the + + *fmt*: '-' + The plot format symbol for *y*. If *fmt* is *None*, just plot the errorbars with no line symbols. This can be useful for creating a bar plot with errorbars. - ecolor: [ None | mpl color ] + + *ecolor*: [ None | mpl color ] a matplotlib color arg which gives the color the errorbar lines; if - None, use the marker color. - elinewidth: scalar - the linewidth of the errorbar lines. If None, use the linewidth. - capsize: scalar + *None*, use the marker color. + + *elinewidth*: scalar + the linewidth of the errorbar lines. If *None*, use the linewidth. + + *capsize*: scalar the size of the error bar caps in points - barsabove: [ True | False ] - if True, will plot the errorbars above the plot symbols. Default is - below. - lolims/uplims/xlolims/xuplims: [ False | True ] - These arguments can be used to indicate that a value gives only - upper/lower limits. In that case a caret symbol is used to indicate - this. lims-arguments may be of the same type as xerr and yerr. + *barsabove*: [ True | False ] + if *True*, will plot the errorbars above the plot + symbols. Default is below. + + *lolims*/*uplims*/*xlolims*/*xuplims*: [ False | True ] + These arguments can be used to indicate that a value gives + only upper/lower limits. In that case a caret symbol is + used to indicate this. lims-arguments may be of the same + type as *xerr* and *yerr*. + All other keyword arguments are passed on to the plot command for the markers, so you can add additional key=value pairs to control the errorbar markers. For example, this code makes big red squares with @@ -4018,16 +4139,20 @@ errorbar(x, y, yerr, marker='s', mfc='red', mec='green', ms=20, mew=4) - where mfc, mec, ms and mew are aliases for the longer property names, - markerfacecolor, markeredgecolor, markersize and markeredgewith. + where *mfc*, *mec*, *ms* and *mew* are aliases for the longer + property names, *markerfacecolor*, *markeredgecolor*, *markersize* + and *markeredgewith*. valid kwargs for the marker properties are + %(Line2D)s Return value is a length 3 tuple. The first element is the - Line2D instance for the y symbol lines. The second element is - a list of error bar cap lines, the third element is a list of - line collections for the horizontal and vertical error ranges + :class:`~matplotlib.lines.Line2D` instance for the *y* symbol + lines. The second element is a list of error bar cap lines, + the third element is a list of + :class:`~matplotlib.collections.LineCollection` instances for + the horizontal and vertical error ranges. """ self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) @@ -4196,38 +4321,38 @@ boxplot(x, notch=0, sym='+', vert=1, whis=1.5, positions=None, widths=None) - Make a box and whisker plot for each column of x or - each vector in sequence x. - The box extends from the lower to upper quartile values - of the data, with a line at the median. The whiskers - extend from the box to show the range of the data. Flier - points are those past the end of the whiskers. + Make a box and whisker plot for each column of *x* or each + vector in sequence *x*. The box extends from the lower to + upper quartile values of the data, with a line at the median. + The whiskers extend from the box to show the range of the + data. Flier points are those past the end of the whiskers. - ``notch = 0`` (default) produces a rectangular box plot. - ``notch = 1`` will produce a notched box plot + - *notch* = 0 (default) produces a rectangular box plot. + - *notch* = 1 will produce a notched box plot - sym (default 'b+') is the default symbol for flier points. + *sym* (default 'b+') is the default symbol for flier points. Enter an empty string ('') if you don't want to show fliers. - ``vert = 1`` (default) makes the boxes vertical. - ``vert = 0`` makes horizontal boxes. This seems goofy, but - that's how Matlab did it. + - *vert* = 1 (default) makes the boxes vertical. + - *vert* = 0 makes horizontal boxes. This seems goofy, but + that's how Matlab did it. - whis (default 1.5) defines the length of the whiskers as + *whis* (default 1.5) defines the length of the whiskers as a function of the inner quartile range. They extend to the most extreme data point within ( ``whis*(75%-25%)`` ) data range. - positions (default 1,2,...,n) sets the horizontal positions of + *positions* (default 1,2,...,n) sets the horizontal positions of the boxes. The ticks and limits are automatically set to match the positions. - widths is either a scalar or a vector and sets the width of + *widths* is either a scalar or a vector and sets the width of each box. The default is 0.5, or ``0.15*(distance between extreme positions)`` if that is smaller. - x is an array or a sequence of vectors. + *x* is an array or a sequence of vectors. - Returns a list of the lines added. + Returns a list of the :class:`matplotlib.lines.Line2D` + instances added. """ if not self._hold: self.cla() @@ -4382,24 +4507,26 @@ vmin=None, vmax=None, alpha=1.0, linewidths=None, verts=None, **kwargs) - Make a scatter plot of x versus y, where x, y are 1-D sequences - of the same length, N. + Make a scatter plot of *x* versus *y*, where *x*, *y* are 1-D + sequences of the same length, *N*. Keyword arguments: - s: + *s*: size in points^2. It is a scalar or an array of the same - length as x and y. - c: - a color. c can be a single color format string, or a - sequence of color specifications of length N, or a sequence - of N numbers to be mapped to colors using the cmap and norm - specified via kwargs (see below). Note that c should not be - a single numeric RGB or RGBA sequence because that is - indistinguishable from an array of values to be colormapped. - c can be a 2-D array in which the rows are RGB or RGBA, - however. - marker: + length as *x* and *y*. + + *c*: + a color. *c* can be a single color format string, or a + sequence of color specifications of length *N*, or a + sequence of *N* numbers to be mapped to colors using the + *cmap* and *norm* specified via kwargs (see below). Note + that *c* should not be a single numeric RGB or RGBA + sequence because that is indistinguishable from an array + of values to be colormapped. *c* can be a 2-D array in + which the rows are RGB or RGBA, however. + + *marker*: can be on... [truncated message content] |