From: <md...@us...> - 2008-06-17 19:08:02
|
Revision: 5585 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5585&view=rev Author: mdboom Date: 2008-06-17 12:07:51 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Minor doc formatting issues. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/lib/matplotlib/transforms.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-17 19:01:38 UTC (rev 5584) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-17 19:07:51 UTC (rev 5585) @@ -56,14 +56,14 @@ def open_group(self, s): """ - Open a grouping element with label ``s.`` Is only currently used by + Open a grouping element with label *s*. Is only currently used by :mod:`~matplotlib.backends.backend_svg` """ pass def close_group(self, s): """ - Close a grouping element with label ``s`` + Close a grouping element with label *s* Is only currently used by :mod:`~matplotlib.backends.backend_svg` """ pass @@ -82,20 +82,19 @@ that behavior, those vertices should be removed before calling this function. - ``gc`` + *gc* the :class:`GraphicsContextBase` instance - ``marker_trans`` + *marker_trans* is an affine transform applied to the marker. - ``trans`` + *trans* is an affine transform applied to the path. This provides a fallback implementation of draw_markers that - makes multiple calls to - :meth:`draw_path`. Some - backends may want to override this method in order to draw the - marker only once and reuse it multiple times. + makes multiple calls to :meth:`draw_path`. Some backends may + want to override this method in order to draw the marker only + once and reuse it multiple times. """ tpath = trans.transform_path(path) for x, y in tpath.vertices: @@ -109,25 +108,23 @@ linestyles, antialiaseds): """ Draws a collection of paths, selecting drawing properties from - the lists ``facecolors``, ``edgecolors``, ``linewidths``, - ``linestyles`` and ``antialiaseds``. `` offsets`` is a list of + the lists *facecolors*, *edgecolors*, *linewidths*, + *linestyles* and *antialiaseds*. *offsets* is a list of offsets to apply to each of the paths. The offsets in - ``offsets`` are first transformed by ``offsetTrans`` before + *offsets* are first transformed by *offsetTrans* before being applied. This provides a fallback implementation of - draw_path_collection that makes multiple calls to draw_path. - Some backends may want to override this in order to render - each set of path data only once, and then reference that path - multiple times with the different offsets, colors, styles etc. - The generator methods - :meth:`_iter_collection_raw_paths` - and - :meth:`_iter_collection` - are provided to help with (and standardize) the implementation - across backends. It is highly recommended to use those - generators, so that changes to the behavior of - draw_path_collection can be made globally. + :meth:`draw_path_collection` that makes multiple calls to + draw_path. Some backends may want to override this in order + to render each set of path data only once, and then reference + that path multiple times with the different offsets, colors, + styles etc. The generator methods + :meth:`_iter_collection_raw_paths` and + :meth:`_iter_collection` are provided to help with (and + standardize) the implementation across backends. It is highly + recommended to use those generators, so that changes to the + behavior of :meth:`draw_path_collection` can be made globally. """ path_ids = [] for path, transform in self._iter_collection_raw_paths( @@ -147,8 +144,9 @@ offsets, offsetTrans, facecolors, antialiased, showedges): """ - This provides a fallback implementation of draw_quad_mesh that - generates paths and then calls :meth:`draw_path_collection`. + This provides a fallback implementation of + :meth:`draw_quad_mesh` that generates paths and then calls + :meth:`draw_path_collection`. """ from matplotlib.collections import QuadMesh paths = QuadMesh.convert_mesh_to_paths( @@ -180,7 +178,7 @@ :meth:`draw_path_collection`. The backend should take each yielded path and transform and - create an object can be referenced (reused) later. + create an object that can be referenced (reused) later. """ Npaths = len(paths) Ntransforms = len(all_transforms) @@ -208,20 +206,20 @@ This method yields all of the path, offset and graphics context combinations to draw the path collection. The caller should already have looped over the results of - _iter_collection_raw_paths to draw this collection. + :meth:`_iter_collection_raw_paths` to draw this collection. The arguments should be the same as that passed into - draw_path_collection, with the exception of path_ids, which - is a list of arbitrary objects that the backend will use to - reference one of the paths created in the - _iter_collection_raw_paths stage. + :meth:`draw_path_collection`, with the exception of + *path_ids*, which is a list of arbitrary objects that the + backend will use to reference one of the paths created in the + :meth:`_iter_collection_raw_paths` stage. - Each yielded result is of the form: + Each yielded result is of the form:: xo, yo, path_id, gc, rgbFace - where xo, yo is an offset; path_id is one of the elements of - path_ids; gc is a graphics context and rgbFace is a color to + where *xo*, *yo* is an offset; *path_id* is one of the elements of + *path_ids*; *gc* is a graphics context and *rgbFace* is a color to use for filling the path. """ Npaths = len(path_ids) @@ -280,18 +278,18 @@ """ Draw the image instance into the current axes; - ``x`` + *x* is the distance in pixels from the left hand side of the canvas. - ``y`` + *y* the distance from the origin. That is, if origin is upper, y is the distance from top. If origin is lower, y is the distance from bottom - ``im`` + *im* the :class:`matplotlib._image.Image` instance - ``bbox`` + *bbox* a :class:`matplotlib.transforms.Bbox` instance for clipping, or None @@ -312,22 +310,22 @@ """ Draw the text instance - ``gc`` + *gc* the :class:`GraphicsContextBase` instance - ``x`` + *x* the x location of the text in display coords - ``y`` + *y* the y location of the text in display coords - ``s`` + *s* a :class:`matplotlib.text.Text` instance - ``prop`` + *prop* a :class:`matplotlib.font_manager.FontProperties` instance - ``angle`` + *angle* the rotation angle in degrees **backend implementers note** @@ -382,7 +380,7 @@ """ Convert points to display units - ``points`` + *points* a float or a numpy array of float return points converted to pixels @@ -559,10 +557,10 @@ """ Set the dash style for the gc. - ``dash_offset`` + *dash_offset* is the offset (usually 0). - ``dash_list`` + *dash_list* specifies the on-off sequence as points. ``(None, None)`` specifies a solid line """ @@ -574,9 +572,9 @@ html hex color string, an rgb unit tuple, or a float between 0 and 1. In the latter case, grayscale is used. - The :class:`GraphicsContextBase` converts colors to rgb internally. If you - know the color is rgb already, you can set ``isRGB=True`` to - avoid the performace hit of the conversion + The :class:`GraphicsContextBase` converts colors to rgb + internally. If you know the color is rgb already, you can set + ``isRGB=True`` to avoid the performace hit of the conversion """ if isRGB: self._rgb = fg @@ -585,7 +583,7 @@ def set_graylevel(self, frac): """ - Set the foreground color to be a gray level with ``frac`` frac + Set the foreground color to be a gray level with *frac* """ self._rgb = (frac, frac, frac) @@ -634,13 +632,13 @@ :meth:`FigureCanvasBase.mpl_connect`. The following attributes are defined and shown with their default values - ``name`` + *name* the event name - ``canvas`` + *canvas* the FigureCanvas instance generating the event - ``guiEvent`` + *guiEvent* the GUI event that triggered the matplotlib event @@ -657,7 +655,7 @@ In addition to the :class:`Event` attributes, the following event attributes are defined: - ``renderer`` + *renderer* the :class:`RendererBase` instance for the draw event """ @@ -671,10 +669,10 @@ In addition to the :class:`Event` attributes, the following event attributes are defined: - ``width`` + *width* width of the canvas in pixels - ``height`` + *height* height of the canvas in pixels """ @@ -691,19 +689,19 @@ In addition to the :class:`Event` attributes, the following event attributes are defined: - ``x`` + *x* x position - pixels from left of canvas - ``y`` + *y* y position - pixels from bottom of canvas - ``inaxes`` + *inaxes* the :class:`~matplotlib.axes.Axes` instance if mouse is over axes - ``xdata`` + *xdata* x coord of mouse in data coords - ``ydata`` + *ydata* y coord of mouse in data coords """ @@ -715,7 +713,7 @@ def __init__(self, name, canvas, x, y,guiEvent=None): """ - ``x``, ``y`` in figure coords, 0,0 = bottom, left + *x*, *y* in figure coords, 0,0 = bottom, left """ Event.__init__(self, name, canvas,guiEvent=guiEvent) self.x = x @@ -755,10 +753,10 @@ In addition to the :class:`Event` and :class:`LocationEvent` attributes, the following attributes are defined: - ``button`` + *button* button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events) - ``key`` + *key* the key pressed: None, chr(range(255), 'shift', 'win', or 'control' @@ -794,10 +792,10 @@ Attrs: all the :class:`Event` attributes plus - ``mouseevent`` + *mouseevent* the :class:`MouseEvent` that generated the pick - ``artist`` + *artist* the :class:`~matplotlib.artist.Artist` picked other @@ -837,7 +835,7 @@ In addition to the :class:`Event` and :class:`LocationEvent` attributes, the following attributes are defined: - ``key`` + *key* the key pressed: None, chr(range(255), shift, win, or control This interface may change slightly when better support for @@ -864,7 +862,7 @@ Public attributes - ``figure`` + *figure* A :class:`matplotlib.figure.Figure` instance """ @@ -1077,13 +1075,13 @@ Backend derived classes should call this function on any mouse button release. - ``x`` + *x* the canvas coordinates where 0=left - ``y`` + *y* the canvas coordinates where 0=bottom - ``guiEvent`` + *guiEvent* the native UI event that generated the mpl event @@ -1101,13 +1099,13 @@ Backend derived classes should call this function on any motion-notify-event. - ``x`` + *x* the canvas coordinates where 0=left - ``y`` + *y* the canvas coordinates where 0=bottom - ``guiEvent`` + *guiEvent* the native UI event that generated the mpl event @@ -1225,25 +1223,25 @@ Arguments are: - ``filename`` + *filename* can also be a file object on image backends - ``orientation`` + *orientation* only currently applies to PostScript printing. - ``dpi`` + *dpi* the dots per inch to save the figure in; if None, use savefig.dpi - ``facecolor`` + *facecolor* the facecolor of the figure - ``edgecolor`` + *edgecolor* the edgecolor of the figure - ``orientation`` ' + *orientation* ' landscape' | 'portrait' (not supported on all backends) - ``format`` + *format* when set, forcibly set the file format to save to """ if format is None: @@ -1380,10 +1378,10 @@ Public attibutes: - ``canvas`` + *canvas* A :class:`FigureCanvasBase` instance - ``num`` + *num* The figure nuamber """ def __init__(self, canvas, num): Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-06-17 19:01:38 UTC (rev 5584) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-06-17 19:07:51 UTC (rev 5585) @@ -212,7 +212,7 @@ return 1 def is_writable_file_like(obj): - 'return true if *obj* looks like a file object' + 'return true if *obj* looks like a file object with a *write* method' return hasattr(obj, 'write') and callable(obj.write) def is_scalar(obj): @@ -615,8 +615,8 @@ def allequal(seq): """ - return true if all elements of *seq* compare equal. If *seq* is 0 - or 1 length, return *True* + Return *True* if all elements of *seq* compare equal. If *seq* is + 0 or 1 length, return *True* """ if len(seq)<2: return True val = seq[0] @@ -626,14 +626,20 @@ return True def alltrue(seq): - #return true if all elements of seq are true. If seq is empty return false + """ + Return *True* if all elements of *seq* evaluate to *True*. If + *seq* is empty, return *False*. + """ if not len(seq): return False for val in seq: if not val: return False return True def onetrue(seq): - #return true if one element of seq is true. If seq is empty return false + """ + Return *True* if one element of *seq* is *True*. It *seq* is + empty, return *False*. + """ if not len(seq): return False for val in seq: if val: return True @@ -948,8 +954,8 @@ would be overkill. Objects can be joined using :meth:`join`, tested for connectedness - using :meth:`joined`, and all disjoint sets can be retreived using - :meth:`get`. + using :meth:`joined`, and all disjoint sets can be retreived by + using the object as an iterator. The objects being joined must be hashable. @@ -978,8 +984,8 @@ def join(self, a, *args): """ - Join given arguments into the same set. - Accepts one or more arguments. + Join given arguments into the same set. Accepts one or more + arguments. """ mapping = self._mapping set_a = mapping.setdefault(a, [a]) @@ -1018,8 +1024,7 @@ def get_siblings(self, a): """ - Returns all of the items joined with the given item, including - itself. + Returns all of the items joined with *a*, including itself. """ return self._mapping.get(a, [a]) Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008-06-17 19:01:38 UTC (rev 5584) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008-06-17 19:07:51 UTC (rev 5585) @@ -393,27 +393,31 @@ class QuadMesh(Collection): """ Class for the efficient drawing of a quadrilateral mesh. - A quadrilateral mesh consists of a grid of vertices. The dimensions - of this array are (meshWidth+1, meshHeight+1). Each vertex in - the mesh has a different set of "mesh coordinates" representing - its position in the topology of the mesh. For any values (m, n) - such that 0 <= m <= meshWidth and 0 <= n <= meshHeight, the - vertices at mesh coordinates (m, n), (m, n+1), (m+1, n+1), and - (m+1, n) form one of the quadrilaterals in the mesh. There are - thus (meshWidth * meshHeight) quadrilaterals in the mesh. - The mesh need not be regular and the polygons need not be convex. - A quadrilateral mesh is represented by a - (2 x ((meshWidth + 1) * (meshHeight + 1))) numpy array - 'coordinates' where each row is the X and Y coordinates of one - of the vertices. - To define the function that maps from a data point to - its corresponding color, use the set_cmap() function. - Each of these arrays is indexed in row-major order by the - mesh coordinates of the vertex (or the mesh coordinates of - the lower left vertex, in the case of the colors). For example, - the first entry in coordinates is the coordinates of the vertex - at mesh coordinates (0, 0), then the one at (0, 1), then at - (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on. + + A quadrilateral mesh consists of a grid of vertices. The + dimensions of this array are (*meshWidth* + 1, *meshHeight* + + 1). Each vertex in the mesh has a different set of "mesh + coordinates" representing its position in the topology of the + mesh. For any values (*m*, *n*) such that 0 <= *m* <= *meshWidth* + and 0 <= *n* <= *meshHeight*, the vertices at mesh coordinates + (*m*, *n*), (*m*, *n* + 1), (*m* + 1, *n* + 1), and (*m* + 1, *n*) + form one of the quadrilaterals in the mesh. There are thus + (*meshWidth* * *meshHeight*) quadrilaterals in the mesh. The mesh + need not be regular and the polygons need not be convex. + + A quadrilateral mesh is represented by a (2 x ((*meshWidth* + 1) * + (*meshHeight* + 1))) numpy array *coordinates*, where each row is + the *x* and *y* coordinates of one of the vertices. To define the + function that maps from a data point to its corresponding color, + use the :meth:`set_cmap` method. Each of these arrays is indexed in + row-major order by the mesh coordinates of the vertex (or the mesh + coordinates of the lower left vertex, in the case of the + colors). + + For example, the first entry in *coordinates* is the + coordinates of the vertex at mesh coordinates (0, 0), then the one + at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and + so on. """ def __init__(self, meshWidth, meshHeight, coordinates, showedges, antialiased=True): Collection.__init__(self) @@ -441,6 +445,13 @@ #@staticmethod def convert_mesh_to_paths(meshWidth, meshHeight, coordinates): + """ + Converts a given mesh into a sequence of + :class:`matplotlib.path.Path` objects for easier rendering by + backends that do not directly support quadmeshes. + + This function is primarily of use to backend implementers. + """ Path = mpath.Path c = coordinates @@ -502,11 +513,11 @@ def __init__(self, verts, sizes = None, **kwargs): """ *verts* is a sequence of ( *verts0*, *verts1*, ...) where - *verts_i* is a sequence of xy tuples of vertices, or an - equivalent :mod:`numpy` array of shape (nv,2). + *verts_i* is a sequence of *xy* tuples of vertices, or an + equivalent :mod:`numpy` array of shape (*nv*, 2). *sizes* gives the area of the circle circumscribing the - polygon in points^2 + polygon in points^2. %(Collection)s """ @@ -534,16 +545,16 @@ class BrokenBarHCollection(PolyCollection): """ - A collection of horizontal bars spanning yrange with a sequence of - xranges + A collection of horizontal bars spanning *yrange* with a sequence of + *xranges*. """ def __init__(self, xranges, yrange, **kwargs): """ *xranges* - sequence of (xmin, xwidth) + sequence of (*xmin*, *xwidth*) *yrange* - ymin, ywidth + *ymin*, *ywidth* %(Collection)s """ @@ -554,6 +565,7 @@ __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd class RegularPolyCollection(Collection): + """Draw a collection of regular polygons with *numsides*.""" _path_generator = mpath.Path.unit_regular_polygon def __init__(self, @@ -562,22 +574,16 @@ sizes = (1,), **kwargs): """ - Draw a regular polygon with numsides. - - *dpi* - the figure dpi instance, and is required to do the - area scaling. - *numsides* the number of sides of the polygon + *rotation* + the rotation of the polygon in radians + *sizes* gives the area of the circle circumscribing the regular polygon in points^2 - *rotation* - the rotation of the polygon in radians - %(Collection)s Example: see :file:`examples/dynamic_collection.py` for @@ -619,10 +625,16 @@ class StarPolygonCollection(RegularPolyCollection): + """ + Draw a collection of regular stars with *numsides* points.""" + _path_generator = mpath.Path.unit_regular_star class AsteriskPolygonCollection(RegularPolyCollection): + """ + Draw a collection of regular asterisks with *numsides* points.""" + _path_generator = mpath.Path.unit_regular_asterisk @@ -630,8 +642,12 @@ """ All parameters must be sequences or scalars; if scalars, they will be converted to sequences. The property of the ith line - segment is the prop[i % len(props)], ie the properties cycle if - the len of props is less than the number of sements + segment is:: + + prop[i % len(props)] + + i.e., the properties cycle if the ``len`` of props is less than the + number of segments. """ zorder = 2 def __init__(self, segments, # Can be None. @@ -648,7 +664,7 @@ ): """ *segments* - a sequence of ( *line0*, *line1*, *line2*), where:: + a sequence of (*line0*, *line1*, *line2*), where:: linen = (x0, y0), (x1, y1), ... (xm, ym) @@ -656,7 +672,7 @@ can be a different length. *colors* - must be a tuple of RGBA tuples (eg arbitrary color + must be a sequence of RGBA tuples (eg arbitrary color strings, etc, not allowed). *antialiaseds* @@ -792,8 +808,9 @@ a sequence of Patch objects. This list may include a heterogeneous assortment of different patch types. - *match_original* If True, use the colors and linewidths of the - original patches. If False, new colors may be assigned by + *match_original* + If True, use the colors and linewidths of the original + patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap. Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008-06-17 19:01:38 UTC (rev 5584) +++ trunk/matplotlib/lib/matplotlib/path.py 2008-06-17 19:07:51 UTC (rev 5585) @@ -158,9 +158,9 @@ def iter_segments(self): """ Iterates over all of the curve segments in the path. Each - iteration returns a 2-tuple ``(vertices, code)``, where - vertices is a sequence of 1 - 3 coordinate pairs, and code is - one of the ``Path`` codes. + iteration returns a 2-tuple (*vertices*, *code*), where + *vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is + one of the :class:`Path` codes. """ vertices = self.vertices if not len(vertices): Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2008-06-17 19:01:38 UTC (rev 5584) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2008-06-17 19:07:51 UTC (rev 5585) @@ -3,13 +3,13 @@ transformations that is used determine the final position of all elements drawn on the canvas. -Transforms are composed into trees of ``TransformNode`` objects whose -actual value depends on their children. When the contents of children -change, their parents are automatically invalidated. The next time an -invalidated transform is accessed, it is recomputed to reflect those -changes. This invalidation/caching approach prevents unnecessary -recomputations of transforms, and contributes to better interactive -performance. +Transforms are composed into trees of :class:`TransformNode` objects +whose actual value depends on their children. When the contents of +children change, their parents are automatically invalidated. The +next time an invalidated transform is accessed, it is recomputed to +reflect those changes. This invalidation/caching approach prevents +unnecessary recomputations of transforms, and contributes to better +interactive performance. For example, here is a graph of the transform tree used to plot data to the graph: @@ -395,7 +395,7 @@ def overlaps(self, other): """ Returns True if this bounding box overlaps with the given - bounding box ``other``. + bounding box *other*. """ ax1, ay1, ax2, ay2 = self._get_extents() bx1, by1, bx2, by2 = other._get_extents() @@ -445,7 +445,7 @@ def fully_overlaps(self, other): """ Returns True if this bounding box overlaps with the given - bounding box ``other``, but not on its edge alone.""" + bounding box *other*, but not on its edge alone.""" ax1, ay1, ax2, ay2 = self._get_extents() bx1, by1, bx2, by2 = other._get_extents() @@ -503,7 +503,7 @@ - E for left - etc. - Optional argument ``container`` is the box within which the :class:`Bbox` + Optional argument *container* is the box within which the :class:`Bbox` is positioned; it defaults to the initial :class:`Bbox`. """ if container is None: @@ -533,10 +533,10 @@ """ Return a copy of the :class:`Bbox`, shrunk so that it is as large as it can be while having the desired aspect ratio, - ``box_aspect``. If the box coordinates are relative---that + *box_aspect*. If the box coordinates are relative---that is, fractions of a larger box such as a figure---then the physical aspect ratio of that figure is specified with - ``fig_aspect``, so that ``box_aspect`` can also be given as a + *fig_aspect*, so that *box_aspect* can also be given as a ratio of the absolute dimensions, not the relative dimensions. """ assert box_aspect > 0 and fig_aspect > 0 @@ -558,7 +558,7 @@ Returns a list of new :class:`Bbox` objects formed by splitting the original one with vertical lines at fractional - positions f1, f2, ... + positions *f1*, *f2*, ... """ boxes = [] xf = [0] + list(args) + [1] @@ -574,7 +574,7 @@ Returns a list of new :class:`Bbox` objects formed by splitting the original one with horizontal lines at fractional - positions f1, f2, ... + positions *f1*, *f2*, ... """ boxes = [] yf = [0] + list(args) + [1] @@ -612,8 +612,8 @@ def expanded(self, sw, sh): """ Return a new :class:`Bbox` which is this :class:`Bbox` - expanded around its center by the given factors ``sw`` and - ``sh``. + expanded around its center by the given factors *sw* and + *sh*. """ width = self.width height = self.height @@ -641,8 +641,8 @@ """ Return an array of points which are the four corners of this rectangle. For example, if this :class:`Bbox` is defined by - the points (a, b) and (c, d), ``corners`` returns (a, b), (a, - d), (c, b) and (c, d). + the points (*a*, *b*) and (*c*, *d*), :meth:`corners` returns + (*a*, *b*), (*a*, *d*), (*c*, *b*) and (*c*, *d*). """ l, b, r, t = self.get_points().flatten() return np.array([[l, b], [l, t], [r, b], [r, t]]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |