387 lines (337 with data), 29.3 kB
@header@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="matplotlib.html"><font color="#ffffff">matplotlib</font></a>.contour</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/contour.py">/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/contour.py</a></font></td></tr></table>
<p><tt>These are classes to support contour plotting and<br>
labelling for the axes class</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="matplotlib._cntr.html">matplotlib._cntr</a><br>
<a href="matplotlib.cbook.html">matplotlib.cbook</a><br>
<a href="matplotlib.cm.html">matplotlib.cm</a><br>
<a href="matplotlib.collections.html">matplotlib.collections</a><br>
</td><td width="25%" valign=top><a href="matplotlib.colors.html">matplotlib.colors</a><br>
<a href="matplotlib.font_manager.html">matplotlib.font_manager</a><br>
<a href="numpy.ma.html">numpy.ma</a><br>
<a href="matplotlib.html">matplotlib</a><br>
</td><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
<a href="matplotlib.path.html">matplotlib.path</a><br>
<a href="matplotlib.text.html">matplotlib.text</a><br>
<a href="matplotlib.ticker.html">matplotlib.ticker</a><br>
</td><td width="25%" valign=top><a href="warnings.html">warnings</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.contour.html#ContourSet">ContourSet</a>(<a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a>, <a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="matplotlib.contour.html#ContourSet">ContourSet</a>(<a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a>, <a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a>)
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ContourLabeler">class <strong>ContourLabeler</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Mixin to provide labelling capability to <a href="#ContourSet">ContourSet</a><br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="ContourLabeler-add_label"><strong>add_label</strong></a>(self, x, y, rotation, lev, cvalue)</dt></dl>
<dl><dt><a name="ContourLabeler-calc_label_rot_and_inline"><strong>calc_label_rot_and_inline</strong></a>(self, slc, ind, lw, lc<font color="#909090">=None</font>, spacing<font color="#909090">=5</font>)</dt><dd><tt>This function calculates the appropriate label rotation given<br>
the linecontour coordinates in screen units, the index of the<br>
label location and the label width.<br>
<br>
It will also break contour and calculate inlining if *lc* is<br>
not empty (lc defaults to the empty list if None). *spacing*<br>
is the space around the label in pixels to leave empty.<br>
<br>
Do both of these tasks at once to avoid calling cbook.path_length<br>
multiple times, which is relatively costly.<br>
<br>
The method used here involves calculating the path length<br>
along the contour in pixel coordinates and then looking<br>
approximately label width / 2 away from central point to<br>
determine rotation and then to break contour if desired.</tt></dd></dl>
<dl><dt><a name="ContourLabeler-clabel"><strong>clabel</strong></a>(self, *args, **kwargs)</dt><dd><tt>call signature::<br>
<br>
<a href="#ContourLabeler-clabel">clabel</a>(cs, **kwargs)<br>
<br>
adds labels to line contours in *cs*, where *cs* is a<br>
:class:`~matplotlib.contour.<a href="#ContourSet">ContourSet</a>` object returned by<br>
contour.<br>
<br>
::<br>
<br>
<a href="#ContourLabeler-clabel">clabel</a>(cs, v, **kwargs)<br>
<br>
only labels contours listed in *v*.<br>
<br>
Optional keyword arguments:<br>
<br>
*fontsize*:<br>
See <a href="http://matplotlib.sf.net/fonts.html">http://matplotlib.sf.net/fonts.html</a><br>
<br>
.. TODO: Update this link to new fonts document<br>
<br>
*colors*:<br>
- if *None*, the color of each label matches the color of<br>
the corresponding contour<br>
<br>
- if one string color, e.g. *colors* = 'r' or *colors* =<br>
'red', all labels will be plotted in this color<br>
<br>
- if a tuple of matplotlib color args (string, float, rgb, etc),<br>
different labels will be plotted in different colors in the order<br>
specified<br>
<br>
*inline*:<br>
controls whether the underlying contour is removed or<br>
not. Default is *True*.<br>
<br>
*inline_spacing*:<br>
space in pixels to leave on each side of label when<br>
placing inline. Defaults to 5. This spacing will be<br>
exact for labels at locations where the contour is<br>
straight, less so for labels on curved contours.<br>
<br>
*fmt*:<br>
a format string for the label. Default is '%1.3f'<br>
Alternatively, this can be a dictionary matching contour<br>
levels with arbitrary strings to use for each contour level<br>
(i.e., fmt[level]=string)<br>
<br>
*manual*:<br>
if *True*, contour labels will be placed manually using<br>
mouse clicks. Click the first button near a contour to<br>
add a label, click the second button (or potentially both<br>
mouse buttons at once) to finish adding labels. The third<br>
button can be used to remove the last label added, but<br>
only if labels are not inline.</tt></dd></dl>
<dl><dt><a name="ContourLabeler-get_label_coords"><strong>get_label_coords</strong></a>(self, distances, XX, YY, ysize, lw)</dt><dd><tt>labels are ploted at a location with the smallest<br>
dispersion of the contour from a straight line<br>
unless there's another label nearby, in which case<br>
the second best place on the contour is picked up<br>
if there's no good place a label isplotted at the<br>
beginning of the contour</tt></dd></dl>
<dl><dt><a name="ContourLabeler-get_label_width"><strong>get_label_width</strong></a>(self, lev, fmt, fsize)</dt><dd><tt>get the width of the label in points</tt></dd></dl>
<dl><dt><a name="ContourLabeler-get_real_label_width"><strong>get_real_label_width</strong></a>(self, lev, fmt, fsize)</dt><dd><tt>This computes actual onscreen label width.<br>
This uses some black magic to determine onscreen extent of non-drawn<br>
label. This magic may not be very robust.</tt></dd></dl>
<dl><dt><a name="ContourLabeler-get_text"><strong>get_text</strong></a>(self, lev, fmt)</dt><dd><tt>get the text of the label</tt></dd></dl>
<dl><dt><a name="ContourLabeler-labels"><strong>labels</strong></a>(self, inline, inline_spacing)</dt></dl>
<dl><dt><a name="ContourLabeler-locate_label"><strong>locate_label</strong></a>(self, linecontour, labelwidth)</dt><dd><tt>find a good place to plot a label (relatively flat<br>
part of the contour) and the angle of rotation for the<br>
text object</tt></dd></dl>
<dl><dt><a name="ContourLabeler-pop_label"><strong>pop_label</strong></a>(self, index<font color="#909090">=-1</font>)</dt><dd><tt>Defaults to removing last label, but any index can be supplied</tt></dd></dl>
<dl><dt><a name="ContourLabeler-print_label"><strong>print_label</strong></a>(self, linecontour, labelwidth)</dt><dd><tt>if contours are too short, don't plot a label</tt></dd></dl>
<dl><dt><a name="ContourLabeler-set_label_props"><strong>set_label_props</strong></a>(self, label, text, color)</dt><dd><tt>set the label properties - color, fontsize, text</tt></dd></dl>
<dl><dt><a name="ContourLabeler-too_close"><strong>too_close</strong></a>(self, x, y, lw)</dt><dd><tt>if there's a label already nearby, find a better place</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ContourSet">class <strong>ContourSet</strong></a>(<a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a>, <a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Create and store a set of contour lines or filled regions.<br>
<br>
User-callable method: clabel<br>
<br>
Useful attributes:<br>
ax:<br>
the axes object in which the contours are drawn<br>
collections:<br>
a silent_list of LineCollections or PolyCollections<br>
levels:<br>
contour levels<br>
layers:<br>
same as levels for line contours; half-way between<br>
levels for filled contours. See _process_colors method.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="matplotlib.contour.html#ContourSet">ContourSet</a></dd>
<dd><a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a></dd>
<dd><a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="ContourSet-__init__"><strong>__init__</strong></a>(self, ax, *args, **kwargs)</dt><dd><tt>Draw contour lines or filled regions, depending on<br>
whether keyword arg 'filled' is False (default) or True.<br>
<br>
The first argument of the initializer must be an axes<br>
object. The remaining arguments and keyword arguments<br>
are described in <a href="#ContourSet">ContourSet</a>.contour_doc.</tt></dd></dl>
<dl><dt><a name="ContourSet-changed"><strong>changed</strong></a>(self)</dt></dl>
<dl><dt><a name="ContourSet-find_nearest_contour"><strong>find_nearest_contour</strong></a>(self, x, y, indices<font color="#909090">=None</font>, pixel<font color="#909090">=True</font>)</dt><dd><tt>Finds contour that is closest to a point. Defaults to<br>
measuring distance in pixels (screen space - useful for manual<br>
contour labeling), but this can be controlled via a keyword<br>
argument.<br>
<br>
Returns a tuple containing the contour, segment, index of<br>
segment, x & y of segment point and distance to minimum point.<br>
<br>
Call signature::<br>
<br>
conmin,segmin,imin,xmin,ymin,dmin = <a href="#ContourSet-find_nearest_contour">find_nearest_contour</a>(<br>
self, x, y, indices=None, pixel=True )<br>
<br>
Optional keyword arguments::<br>
<br>
*indices*:<br>
Indexes of contour levels to consider when looking for<br>
nearest point. Defaults to using all levels.<br>
<br>
*pixel*:<br>
If *True*, measure distance in pixel space, if not, measure<br>
distance in axes space. Defaults to *True*.</tt></dd></dl>
<dl><dt><a name="ContourSet-get_alpha"><strong>get_alpha</strong></a>(self)</dt><dd><tt>returns alpha to be applied to all <a href="#ContourSet">ContourSet</a> artists</tt></dd></dl>
<dl><dt><a name="ContourSet-set_alpha"><strong>set_alpha</strong></a>(self, alpha)</dt><dd><tt>sets alpha for all <a href="#ContourSet">ContourSet</a> artists</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>contour_doc</strong> = '<font color="#c040c0">\n</font> :func:`~matplotlib.pyplot.contour` and<font color="#c040c0">\n</font>...le:**<font color="#c040c0">\n\n</font> .. plot:: contour_demo.py<font color="#c040c0">\n</font> '</dl>
<hr>
Methods inherited from <a href="matplotlib.cm.html#ScalarMappable">matplotlib.cm.ScalarMappable</a>:<br>
<dl><dt><a name="ContourSet-add_checker"><strong>add_checker</strong></a>(self, checker)</dt><dd><tt>Add an entry to a dictionary of boolean flags<br>
that are set to True when the mappable is changed.</tt></dd></dl>
<dl><dt><a name="ContourSet-autoscale"><strong>autoscale</strong></a>(self)</dt><dd><tt>Autoscale the scalar limits on the norm instance using the<br>
current array</tt></dd></dl>
<dl><dt><a name="ContourSet-autoscale_None"><strong>autoscale_None</strong></a>(self)</dt><dd><tt>Autoscale the scalar limits on the norm instance using the<br>
current array, changing only limits that are None</tt></dd></dl>
<dl><dt><a name="ContourSet-check_update"><strong>check_update</strong></a>(self, checker)</dt><dd><tt>If mappable has changed since the last check,<br>
return True; else return False</tt></dd></dl>
<dl><dt><a name="ContourSet-get_array"><strong>get_array</strong></a>(self)</dt><dd><tt>Return the array</tt></dd></dl>
<dl><dt><a name="ContourSet-get_clim"><strong>get_clim</strong></a>(self)</dt><dd><tt>return the min, max of the color limits for image scaling</tt></dd></dl>
<dl><dt><a name="ContourSet-get_cmap"><strong>get_cmap</strong></a>(self)</dt><dd><tt>return the colormap</tt></dd></dl>
<dl><dt><a name="ContourSet-set_array"><strong>set_array</strong></a>(self, A)</dt><dd><tt>Set the image array from numpy array *A*</tt></dd></dl>
<dl><dt><a name="ContourSet-set_clim"><strong>set_clim</strong></a>(self, vmin<font color="#909090">=None</font>, vmax<font color="#909090">=None</font>)</dt><dd><tt>set the norm limits for image scaling; if *vmin* is a length2<br>
sequence, interpret it as ``(vmin, vmax)`` which is used to<br>
support setp<br>
<br>
ACCEPTS: a length 2 sequence of floats</tt></dd></dl>
<dl><dt><a name="ContourSet-set_cmap"><strong>set_cmap</strong></a>(self, cmap)</dt><dd><tt>set the colormap for luminance data<br>
<br>
ACCEPTS: a colormap</tt></dd></dl>
<dl><dt><a name="ContourSet-set_colorbar"><strong>set_colorbar</strong></a>(self, im, ax)</dt><dd><tt>set the colorbar image and axes associated with mappable</tt></dd></dl>
<dl><dt><a name="ContourSet-set_norm"><strong>set_norm</strong></a>(self, norm)</dt><dd><tt>set the normalization instance</tt></dd></dl>
<dl><dt><a name="ContourSet-to_rgba"><strong>to_rgba</strong></a>(self, x, alpha<font color="#909090">=1.0</font>, bytes<font color="#909090">=False</font>)</dt><dd><tt>Return a normalized rgba array corresponding to *x*. If *x*<br>
is already an rgb array, insert *alpha*; if it is already<br>
rgba, return it unchanged. If *bytes* is True, return rgba as<br>
4 uint8s instead of 4 floats.</tt></dd></dl>
<hr>
Methods inherited from <a href="matplotlib.contour.html#ContourLabeler">ContourLabeler</a>:<br>
<dl><dt><a name="ContourSet-add_label"><strong>add_label</strong></a>(self, x, y, rotation, lev, cvalue)</dt></dl>
<dl><dt><a name="ContourSet-calc_label_rot_and_inline"><strong>calc_label_rot_and_inline</strong></a>(self, slc, ind, lw, lc<font color="#909090">=None</font>, spacing<font color="#909090">=5</font>)</dt><dd><tt>This function calculates the appropriate label rotation given<br>
the linecontour coordinates in screen units, the index of the<br>
label location and the label width.<br>
<br>
It will also break contour and calculate inlining if *lc* is<br>
not empty (lc defaults to the empty list if None). *spacing*<br>
is the space around the label in pixels to leave empty.<br>
<br>
Do both of these tasks at once to avoid calling cbook.path_length<br>
multiple times, which is relatively costly.<br>
<br>
The method used here involves calculating the path length<br>
along the contour in pixel coordinates and then looking<br>
approximately label width / 2 away from central point to<br>
determine rotation and then to break contour if desired.</tt></dd></dl>
<dl><dt><a name="ContourSet-clabel"><strong>clabel</strong></a>(self, *args, **kwargs)</dt><dd><tt>call signature::<br>
<br>
<a href="#ContourSet-clabel">clabel</a>(cs, **kwargs)<br>
<br>
adds labels to line contours in *cs*, where *cs* is a<br>
:class:`~matplotlib.contour.<a href="#ContourSet">ContourSet</a>` object returned by<br>
contour.<br>
<br>
::<br>
<br>
<a href="#ContourSet-clabel">clabel</a>(cs, v, **kwargs)<br>
<br>
only labels contours listed in *v*.<br>
<br>
Optional keyword arguments:<br>
<br>
*fontsize*:<br>
See <a href="http://matplotlib.sf.net/fonts.html">http://matplotlib.sf.net/fonts.html</a><br>
<br>
.. TODO: Update this link to new fonts document<br>
<br>
*colors*:<br>
- if *None*, the color of each label matches the color of<br>
the corresponding contour<br>
<br>
- if one string color, e.g. *colors* = 'r' or *colors* =<br>
'red', all labels will be plotted in this color<br>
<br>
- if a tuple of matplotlib color args (string, float, rgb, etc),<br>
different labels will be plotted in different colors in the order<br>
specified<br>
<br>
*inline*:<br>
controls whether the underlying contour is removed or<br>
not. Default is *True*.<br>
<br>
*inline_spacing*:<br>
space in pixels to leave on each side of label when<br>
placing inline. Defaults to 5. This spacing will be<br>
exact for labels at locations where the contour is<br>
straight, less so for labels on curved contours.<br>
<br>
*fmt*:<br>
a format string for the label. Default is '%1.3f'<br>
Alternatively, this can be a dictionary matching contour<br>
levels with arbitrary strings to use for each contour level<br>
(i.e., fmt[level]=string)<br>
<br>
*manual*:<br>
if *True*, contour labels will be placed manually using<br>
mouse clicks. Click the first button near a contour to<br>
add a label, click the second button (or potentially both<br>
mouse buttons at once) to finish adding labels. The third<br>
button can be used to remove the last label added, but<br>
only if labels are not inline.</tt></dd></dl>
<dl><dt><a name="ContourSet-get_label_coords"><strong>get_label_coords</strong></a>(self, distances, XX, YY, ysize, lw)</dt><dd><tt>labels are ploted at a location with the smallest<br>
dispersion of the contour from a straight line<br>
unless there's another label nearby, in which case<br>
the second best place on the contour is picked up<br>
if there's no good place a label isplotted at the<br>
beginning of the contour</tt></dd></dl>
<dl><dt><a name="ContourSet-get_label_width"><strong>get_label_width</strong></a>(self, lev, fmt, fsize)</dt><dd><tt>get the width of the label in points</tt></dd></dl>
<dl><dt><a name="ContourSet-get_real_label_width"><strong>get_real_label_width</strong></a>(self, lev, fmt, fsize)</dt><dd><tt>This computes actual onscreen label width.<br>
This uses some black magic to determine onscreen extent of non-drawn<br>
label. This magic may not be very robust.</tt></dd></dl>
<dl><dt><a name="ContourSet-get_text"><strong>get_text</strong></a>(self, lev, fmt)</dt><dd><tt>get the text of the label</tt></dd></dl>
<dl><dt><a name="ContourSet-labels"><strong>labels</strong></a>(self, inline, inline_spacing)</dt></dl>
<dl><dt><a name="ContourSet-locate_label"><strong>locate_label</strong></a>(self, linecontour, labelwidth)</dt><dd><tt>find a good place to plot a label (relatively flat<br>
part of the contour) and the angle of rotation for the<br>
text object</tt></dd></dl>
<dl><dt><a name="ContourSet-pop_label"><strong>pop_label</strong></a>(self, index<font color="#909090">=-1</font>)</dt><dd><tt>Defaults to removing last label, but any index can be supplied</tt></dd></dl>
<dl><dt><a name="ContourSet-print_label"><strong>print_label</strong></a>(self, linecontour, labelwidth)</dt><dd><tt>if contours are too short, don't plot a label</tt></dd></dl>
<dl><dt><a name="ContourSet-set_label_props"><strong>set_label_props</strong></a>(self, label, text, color)</dt><dd><tt>set the label properties - color, fontsize, text</tt></dd></dl>
<dl><dt><a name="ContourSet-too_close"><strong>too_close</strong></a>(self, x, y, lw)</dt><dd><tt>if there's a label already nearby, find a better place</tt></dd></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>division</strong> = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)</td></tr></table>
@footer@