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