Classes for the efficient drawing of large collections of objects that share most properties, e.g. a large number of line segments or polygons.
The classes are not meant to be as flexible as their single element counterparts (e.g. you may not be able to select all line styles) but they are meant to be fast for common use cases (e.g. a bunch of solid line segemnts)
Bases: matplotlib.collections.RegularPolyCollection
Draw a collection of regular asterisks with numsides points.
gives the area of the circle circumscribing the regular polygon in points^2
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Example: see examples/dynamic_collection.py for complete example:
offsets = np.random.rand(20,2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]
black = (0,0,0,1)
collection = RegularPolyCollection(
numsides=5, # a pentagon
rotation=0, sizes=(50,),
facecolors = facecolors,
edgecolors = (black,),
linewidths = (1,),
offsets = offsets,
transOffset = ax.transData,
)
Bases: matplotlib.collections.PolyCollection
A collection of horizontal bars spanning yrange with a sequence of xranges.
ymin, ywidth
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Bases: matplotlib.collections.Collection
A collection of circles, drawn using splines.
Gives the area of the circle in points^2
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Bases: matplotlib.artist.Artist, matplotlib.cm.ScalarMappable
Base class for Collections. Must be subclassed to be usable.
All properties in a collection must be sequences or scalars; if scalars, they will be converted to sequences. The property of the ith element of the collection is:
prop[i % len(props)]
Keyword arguments and default values:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets).
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
The use of ScalarMappable is optional. If the ScalarMappable matrix _A is not None (ie a call to set_array has been made), at draw time a call to scalar mappable will be made to set the face colors.
Create a Collection
%(Collection)s
Test whether the mouse event occurred in the collection.
Returns True | False, dict(ind=itemlist), where every item in itemlist contains the event.
Set the alpha tranparencies of the collection. alpha must be a float.
ACCEPTS: float
Set the antialiasing state for rendering.
ACCEPTS: Boolean or sequence of booleans
Set the antialiasing state for rendering.
ACCEPTS: Boolean or sequence of booleans
Set both the edgecolor and the facecolor. See set_facecolor() and set_edgecolor().
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the edgecolor(s) of the collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence.
If c is ‘face’, the edge color will always be the same as the face color.
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the edgecolor(s) of the collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence.
If c is ‘face’, the edge color will always be the same as the face color.
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the facecolor(s) of the collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the facecolor(s) of the collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
ACCEPTS: float or sequence of floats
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
ACCEPTS: float or sequence of floats
Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence
ACCEPTS: float or sequence of floats
Set the offsets for the collection. offsets can be a scalar or a sequence.
ACCEPTS: float or sequence of floats
Bases: matplotlib.collections.Collection
All parameters must be sequences or scalars; if scalars, they will be converted to sequences. The property of the ith line segment is:
prop[i % len(props)]
i.e., the properties cycle if the len of props is less than the number of segments.
a sequence of (line0, line1, line2), where:
linen = (x0, y0), (x1, y1), ... (xm, ym)
or the equivalent numpy array with two columns. Each line can be a different length.
a string or dash tuple. The dash tuple is:
(offset, onoffseq),
where onoffseq is an even length tuple of on and off ink in points.
If linewidths, colors, or antialiaseds is None, they default to their rcParams setting, in sequence form.
If offsets and transOffset are not None, then offsets are transformed by transOffset and applied after the segments have been transformed to display coordinates.
If offsets is not None but transOffset is None, then the offsets are added to the segments before any transformation. In this case, a single offset can be specified as:
offsets=(xo,yo)
and this value will be added cumulatively to each successive segment, so as to produce a set of successively offset curves.
pickradius is the tolerance for mouse clicks picking a line. The default is 5 pt.
The use of ScalarMappable is optional. If the ScalarMappable matrix _A is not None (ie a call to set_array() has been made), at draw time a call to scalar mappable will be made to set the colors.
Set the color(s) of the line collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Set the color(s) of the line collection. c can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples
Bases: matplotlib.collections.Collection
A generic collection of patches.
This makes it easier to assign a color map to a heterogeneous collection of patches.
This also may improve plotting speed, since PatchCollection will draw faster than a large number of patches.
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
The use of ScalarMappable is optional. If the ScalarMappable matrix _A is not None (ie a call to set_array has been made), at draw time a call to scalar mappable will be made to set the face colors.
Bases: matplotlib.collections.Collection
verts is a sequence of ( verts0, verts1, ...) where verts_i is a sequence of xy tuples of vertices, or an equivalent numpy array of shape (nv, 2).
sizes is None (default) or a sequence of floats that scale the corresponding verts_i. The scaling is applied before the Artist master transform; if the latter is an identity transform, then the overall scaling is such that if verts_i specify a unit square, then sizes_i is the area of that square in points^2. If len(sizes) < nv, the additional values will be taken cyclically from the array.
closed, when True, will explicitly close the polygon.
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Bases: matplotlib.collections.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() 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.
Converts a given mesh into a sequence of matplotlib.path.Path objects for easier rendering by backends that do not directly support quadmeshes.
This function is primarily of use to backend implementers.
Bases: matplotlib.collections.Collection
Draw a collection of regular polygons with numsides.
gives the area of the circle circumscribing the regular polygon in points^2
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Example: see examples/dynamic_collection.py for complete example:
offsets = np.random.rand(20,2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]
black = (0,0,0,1)
collection = RegularPolyCollection(
numsides=5, # a pentagon
rotation=0, sizes=(50,),
facecolors = facecolors,
edgecolors = (black,),
linewidths = (1,),
offsets = offsets,
transOffset = ax.transData,
)
Bases: matplotlib.collections.RegularPolyCollection
Draw a collection of regular stars with numsides points.
gives the area of the circle circumscribing the regular polygon in points^2
Valid Collection keyword arguments:
- edgecolors: None
- facecolors: None
- linewidths: None
- antialiaseds: None
- offsets: None
- transOffset: transforms.IdentityTransform()
- norm: None (optional for matplotlib.cm.ScalarMappable)
- cmap: None (optional for matplotlib.cm.ScalarMappable)
offsets and transOffset are used to translate the patch after rendering (default no offsets)
If any of edgecolors, facecolors, linewidths, antialiaseds are None, they default to their matplotlib.rcParams patch setting, in sequence form.
Example: see examples/dynamic_collection.py for complete example:
offsets = np.random.rand(20,2)
facecolors = [cm.jet(x) for x in np.random.rand(20)]
black = (0,0,0,1)
collection = RegularPolyCollection(
numsides=5, # a pentagon
rotation=0, sizes=(50,),
facecolors = facecolors,
edgecolors = (black,),
linewidths = (1,),
offsets = offsets,
transOffset = ax.transData,
)