From: <ds...@us...> - 2008-06-23 18:15:44
|
Revision: 5651 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5651&view=rev Author: dsdale Date: 2008-06-23 11:15:01 -0700 (Mon, 23 Jun 2008) Log Message: ----------- updated axis docstrings converted colors docstrings, added to api reference Modified Paths: -------------- trunk/matplotlib/doc/api/index.rst trunk/matplotlib/doc/devel/outline.rst trunk/matplotlib/lib/matplotlib/axis.py trunk/matplotlib/lib/matplotlib/colors.py Added Paths: ----------- trunk/matplotlib/doc/api/colors_api.rst Added: trunk/matplotlib/doc/api/colors_api.rst =================================================================== --- trunk/matplotlib/doc/api/colors_api.rst (rev 0) +++ trunk/matplotlib/doc/api/colors_api.rst 2008-06-23 18:15:01 UTC (rev 5651) @@ -0,0 +1,12 @@ +***************** +matplotlib colors +***************** + + +:mod:`matplotlib.colors` +======================== + +.. automodule:: matplotlib.colors + :members: + :undoc-members: + :show-inheritance: Modified: trunk/matplotlib/doc/api/index.rst =================================================================== --- trunk/matplotlib/doc/api/index.rst 2008-06-23 17:46:26 UTC (rev 5650) +++ trunk/matplotlib/doc/api/index.rst 2008-06-23 18:15:01 UTC (rev 5651) @@ -21,5 +21,6 @@ cm_api.rst collections_api.rst colorbar_api.rst + colors_api.rst pyplot_api.rst index_backend_api.rst Modified: trunk/matplotlib/doc/devel/outline.rst =================================================================== --- trunk/matplotlib/doc/devel/outline.rst 2008-06-23 17:46:26 UTC (rev 5650) +++ trunk/matplotlib/doc/devel/outline.rst 2008-06-23 18:15:01 UTC (rev 5651) @@ -114,13 +114,13 @@ afm converted artist converted axes converted -axis needs conversion -backend_bases needs conversion -cbook needs conversion -cm needs conversion -collections needs conversion -colorbar needs conversion -colors Darren needs conversion +axis converted +backend_bases converted +cbook converted +cm converted +collections converted +colorbar converted +colors converted contour needs conversion dates Darren needs conversion dviread Darren needs conversion @@ -137,7 +137,7 @@ patches needs conversion path needs conversion pylab needs conversion -pyplot needs conversion +pyplot converted quiver needs conversion rcsetup needs conversion scale needs conversion Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2008-06-23 17:46:26 UTC (rev 5650) +++ trunk/matplotlib/lib/matplotlib/axis.py 2008-06-23 18:15:01 UTC (rev 5651) @@ -315,7 +315,7 @@ return l def update_position(self, loc): - 'Set the location of tick in data coords with scalar loc' + 'Set the location of tick in data coords with scalar *loc*' x = loc nonlinear = (hasattr(self.axes, 'yaxis') and @@ -504,8 +504,8 @@ """ Public attributes - * transData - transform data coords to display coords - * transAxis - transform axis coords to display coords + * :attr:`transData` - transform data coords to display coords + * :attr:`transAxis` - transform axis coords to display coords """ LABELPAD = 5 @@ -909,14 +909,14 @@ def grid(self, b=None, which='major', **kwargs): """ - Set the axis grid on or off; b is a boolean use which = + Set the axis grid on or off; b is a boolean use *which* = 'major' | 'minor' to set the grid for major or minor ticks - if b is None and len(kwargs)==0, toggle the grid state. If - kwargs are supplied, it is assumed you want the grid on and b + if *b* is *None* and len(kwargs)==0, toggle the grid state. If + *kwargs* are supplied, it is assumed you want the grid on and *b* will be set to True - kwargs are used to set the line properties of the grids, eg, + *kwargs* are used to set the line properties of the grids, eg, xax.grid(color='r', linestyle='-', linewidth=2) """ @@ -939,8 +939,8 @@ def update_units(self, data): """ - introspect data for units converter and update the - axis.converter instance if necessary. Return true is data is + introspect *data* for units converter and update the + axis.converter instance if necessary. Return *True* is *data* is registered for unit conversion """ @@ -1022,7 +1022,7 @@ """ Set the formatter of the major ticker - ACCEPTS: A Formatter instance + ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance """ self.major.formatter = formatter formatter.set_axis(self) @@ -1032,7 +1032,7 @@ """ Set the formatter of the minor ticker - ACCEPTS: A Formatter instance + ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance """ self.minor.formatter = formatter formatter.set_axis(self) @@ -1042,7 +1042,7 @@ """ Set the locator of the major ticker - ACCEPTS: a Locator instance + ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance """ self.major.locator = locator locator.set_axis(self) @@ -1052,7 +1052,7 @@ """ Set the locator of the minor ticker - ACCEPTS: a Locator instance + ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance """ self.minor.locator = locator locator.set_axis(self) @@ -1069,7 +1069,7 @@ def set_ticklabels(self, ticklabels, *args, **kwargs): """ Set the text values of the tick labels. Return a list of Text - instances. Use kwarg minor=True to select minor ticks. + instances. Use *kwarg* *minor=True* to select minor ticks. ACCEPTS: sequence of strings """ @@ -1128,11 +1128,11 @@ raise NotImplementedError('Derived must override') def pan(self, numsteps): - 'Pan numticks (can be positive or negative)' + 'Pan *numsteps* (can be positive or negative)' self.major.locator.pan(numsteps) def zoom(self, direction): - "Zoom in/out on axis; if direction is >0 zoom in, else zoom out" + "Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out" self.major.locator.zoom(direction) class XAxis(Axis): @@ -1372,7 +1372,7 @@ def contains(self,mouseevent): """Test whether the mouse event occurred in the y axis. - Returns T/F, {} + Returns *True* | *False* """ if callable(self._contains): return self._contains(self,mouseevent) Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2008-06-23 17:46:26 UTC (rev 5650) +++ trunk/matplotlib/lib/matplotlib/colors.py 2008-06-23 18:15:01 UTC (rev 5651) @@ -18,17 +18,17 @@ w : white Gray shades can be given as a string encoding a float in the 0-1 -range, e.g., +range, e.g.:: color = '0.75' For a greater range of colors, you have two options. You can specify -the color using an html hex string, as in +the color using an html hex string, as in:: color = '#eeefff' -or you can pass an R,G,B tuple, where each of R,G,B are in the range -[0,1]. +or you can pass an *R* , *G* , *B* tuple, where each of *R* , *G* , *B* +are in the range [0,1]. Finally, legal html names for colors, like 'red', 'burlywood' and 'chartreuse' are supported. @@ -203,7 +203,7 @@ def hex2color(s): """ - Take a hex string 's' and return the corresponding rgb 3-tuple + Take a hex string *s* and return the corresponding rgb 3-tuple Example: #efefef -> (0.93725, 0.93725, 0.93725) """ if not isinstance(s, basestring): @@ -227,15 +227,17 @@ cache = {} def to_rgb(self, arg): """ - Returns an RGB tuple of three floats from 0-1. + Returns an *RGB* tuple of three floats from 0-1. - arg can be an RGB or RGBA sequence or a string in any of several forms: + *arg* can be an *RGB* or *RGBA* sequence or a string in any of + several forms: + 1) a letter from the set 'rgbcmykw' 2) a hex color string, like '#00FFFF' 3) a standard name, like 'aqua' 4) a float, like '0.4', indicating gray on a 0-1 scale - if arg is RGBA, the A will simply be discarded. + if *arg* is *RGBA*, the *A* will simply be discarded. """ try: return self.cache[arg] except KeyError: pass @@ -283,11 +285,11 @@ def to_rgba(self, arg, alpha=None): """ - Returns an RGBA tuple of four floats from 0-1. + Returns an *RGBA* tuple of four floats from 0-1. - For acceptable values of arg, see to_rgb. - If arg is an RGBA sequence and alpha is not None, - alpha will replace the original A. + For acceptable values of *arg*, see :meth:`to_rgb`. + If *arg* is an *RGBA* sequence and *alpha* is not *None*, + *alpha* will replace the original *A*. """ try: if not cbook.is_string_like(arg) and cbook.iterable(arg): @@ -313,13 +315,13 @@ def to_rgba_array(self, c, alpha=None): """ - Returns an Numpy array of rgba tuples. + Returns an Numpy array of *RGBA* tuples. Accepts a single mpl color spec or a sequence of specs. If the sequence is a list or array, the items are changed in place, but an array copy is still returned. - Special case to handle "no color": if c is "none" (case-insensitive), + Special case to handle "no color": if *c* is "none" (case-insensitive), then an empty array will be returned. Same for an empty list. """ try: @@ -345,9 +347,9 @@ colorConverter = ColorConverter() def makeMappingArray(N, data): - """Create an N-element 1-d lookup table + """Create an *N* -element 1-d lookup table - data represented by a list of x,y0,y1 mapping correspondences. + *data* represented by a list of x,y0,y1 mapping correspondences. Each element in this list represents how a value between 0 and 1 (inclusive) represented by x is mapped to a corresponding value between 0 and 1 (inclusive). The two values of y are to allow @@ -358,7 +360,7 @@ all values of x must be in increasing order. Values between the given mapping points are determined by simple linear interpolation. - The function returns an array "result" where result[x*(N-1)] + The function returns an array "result" where ``result[x*(N-1)]`` gives the closest value for values of x between 0 and 1. """ try: @@ -400,14 +402,16 @@ """Base class for all scalar to rgb mappings Important methods: - set_bad() - set_under() - set_over() + + * :meth:`set_bad` + * :meth:`set_under` + * :meth:`set_over` """ def __init__(self, name, N=256): - """Public class attributes: - self.N: number of rgb quantization levels - self.name: name of colormap + """ + Public class attributes: + :attr:`N` : number of rgb quantization levels + :attr:`name` : name of colormap """ self.name = name @@ -423,7 +427,7 @@ def __call__(self, X, alpha=1.0, bytes=False): """ - X is either a scalar or an array (of any dimension). + *X* is either a scalar or an array (of any dimension). If scalar, a tuple of rgba values is returned, otherwise an array with the new shape = oldshape+(4,). If the X-values are integers, then they are used as indices into the array. @@ -551,13 +555,22 @@ """ Make a colormap from a list of colors. - colors is a list of matplotlib color specifications, - or an equivalent Nx3 floating point array (N rgb values) - name is a string to identify the colormap - N is the number of entries in the map. The default is None, + *colors* + a list of matplotlib color specifications, + or an equivalent Nx3 floating point array (*N* rgb values) + *name* + a string to identify the colormap + *N* + the number of entries in the map. The default is *None*, in which case there is one colormap entry for each - element in the list of colors. If N < len(colors) - the list will be truncated at N. If N > len(colors), + element in the list of colors. If:: + + N < len(colors) + + the list will be truncated at *N*. If:: + + N > len(colors) + the list will be extended by repetition. """ self.colors = colors @@ -600,16 +613,19 @@ """ def __init__(self, vmin=None, vmax=None, clip=False): """ - If vmin or vmax is not given, they are taken from the input's - minimum and maximum value respectively. If clip is True and + If *vmin* or *vmax* is not given, they are taken from the input's + minimum and maximum value respectively. If *clip* is *True* and the given value falls outside the range, the returned value - will be 0 or 1, whichever is closer. Returns 0 if vmin==vmax. + will be 0 or 1, whichever is closer. Returns 0 if:: + + vmin==vmax + Works with scalars or arrays, including masked arrays. If - clip is True, masked values are set to 1; otherwise they + *clip* is *True*, masked values are set to 1; otherwise they remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in the colormap, so it is likely to lead to surprises; therefore the default is - clip=False. + *clip* = *False*. """ self.vmin = vmin self.vmax = vmax @@ -656,7 +672,7 @@ def autoscale(self, A): ''' - Set vmin, vmax to min, max of A. + Set *vmin*, *vmax* to min, max of *A*. ''' self.vmin = ma.minimum(A) self.vmax = ma.maximum(A) @@ -718,8 +734,9 @@ ''' Generate a colormap index based on discrete intervals. - Unlike Normalize or LogNorm, BoundaryNorm maps values - to integers instead of to the interval 0-1. + Unlike :class:`Normalize` or :class:`LogNorm`, + :class:`BoundaryNorm` maps values to integers instead of to the + interval 0-1. Mapping to the 0-1 interval could have been done via piece-wise linear interpolation, but using integers seems @@ -728,17 +745,22 @@ ''' def __init__(self, boundaries, ncolors, clip=False): ''' - args: - boundaries: a monotonically increasing sequence - ncolors: number of colors in the colormap to be used + *boundaries* + a monotonically increasing sequence + *ncolors* + number of colors in the colormap to be used - If b[i] <= v < b[i+1] then v is mapped to color j; + If:: + + b[i] <= v < b[i+1] + + then v is mapped to color j; as i varies from 0 to len(boundaries)-2, j goes from 0 to ncolors-1. Out-of-range values are mapped to -1 if low and ncolors if high; these are converted to valid indices by - Colormap.__call__. + :meth:`Colormap.__call__` . ''' self.clip = clip self.vmin = boundaries[0] @@ -778,7 +800,8 @@ class NoNorm(Normalize): ''' Dummy replacement for Normalize, for the case where we - want to use indices directly in a ScalarMappable. + want to use indices directly in a + :class:`~matplotlib.cm.ScalarMappable` . ''' def __call__(self, value, clip=None): return value This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |