| |
- matplotlib.artist.Artist
-
- QuiverKey
- matplotlib.collections.PolyCollection(matplotlib.collections.PatchCollection)
-
- Quiver
class Quiver(matplotlib.collections.PolyCollection) |
|
Specialized PolyCollection for arrows.
The only API method is set_UVC(), which can be used
to change the size, orientation, and color of the
arrows; their locations are fixed when the class is
instantiated. Possibly this method will be useful
in animations.
Much of the work in this class is done in the draw()
method so that as much information as possible is available
about the plot. In subsequent draw() calls, recalculation
is limited to things that might have changed, so there
should be no performance penalty from putting the calculations
in the draw() method. |
|
- Method resolution order:
- Quiver
- matplotlib.collections.PolyCollection
- matplotlib.collections.PatchCollection
- matplotlib.collections.Collection
- matplotlib.artist.Artist
- matplotlib.cm.ScalarMappable
Methods defined here:
- __init__(self, ax, *args, **kw)
- The constructor takes one required argument, an Axes
instance, followed by the args and kwargs described
by the following pylab interface documentation:
Plot a 2-D field of arrows.
Function signatures:
quiver(U, V, **kw)
quiver(U, V, C, **kw)
quiver(X, Y, U, V, **kw)
quiver(X, Y, U, V, C, **kw)
Arguments:
X, Y give the x and y coordinates of the arrow locations
(default is tail of arrow; see 'pivot' kwarg)
U, V give the x and y components of the arrow vectors
C is an optional array used to map colors to the arrows
All arguments may be 1-D or 2-D arrays or sequences.
If X and Y are absent, they will be generated as a uniform grid.
If U and V are 2-D arrays but X and Y are 1-D, and if
len(X) and len(Y) match the column and row dimensions
of U, then X and Y will be expanded with meshgrid.
U, V, C may be masked arrays, but masked X, Y are not
supported at present.
Keyword arguments (default given first):
* units = 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y'
arrow units; the arrow dimensions *except for length*
are in multiples of this unit.
* scale = None | float
data units per arrow unit, e.g. m/s per plot width;
a smaller scale parameter makes the arrow longer.
If None, a simple autoscaling algorithm is used, based
on the average vector length and the number of vectors.
Arrow dimensions and scales can be in any of several units:
'width' or 'height': the width or height of the axes
'dots' or 'inches': pixels or inches, based on the figure dpi
'x' or 'y': X or Y data units
In all cases the arrow aspect ratio is 1, so that if U==V the angle
of the arrow on the plot is 45 degrees CCW from the X-axis.
The arrows scale differently depending on the units, however.
For 'x' or 'y', the arrows get larger as one zooms in; for other
units, the arrow size is independent of the zoom state. For
'width or 'height', the arrow size increases with the width and
height of the axes, respectively, when the the window is resized;
for 'dots' or 'inches', resizing does not change the arrows.
* width = ? shaft width in arrow units; default depends on
choice of units, above, and number of vectors;
a typical starting value is about
0.005 times the width of the plot.
* headwidth = 3 head width as multiple of shaft width
* headlength = 5 head length as multiple of shaft width
* headaxislength = 4.5 head length at shaft intersection
* minshaft = 1 length below which arrow scales, in units
of head length. Do not set this to less
than 1, or small arrows will look terrible!
* minlength = 1 minimum length as a multiple of shaft width;
if an arrow length is less than this, plot a
dot (hexagon) of this diameter instead.
The defaults give a slightly swept-back arrow; to make the
head a triangle, make headaxislength the same as headlength.
To make the arrow more pointed, reduce headwidth or increase
headlength and headaxislength.
To make the head smaller relative to the shaft, scale down
all the head* parameters.
You will probably do best to leave minshaft alone.
* pivot = 'tail' | 'middle' | 'tip'
The part of the arrow that is at the grid point; the arrow
rotates about this point, hence the name 'pivot'.
* color = 'k' | any matplotlib color spec or sequence of color specs.
This is a synonym for the PolyCollection facecolor kwarg.
If C has been set, 'color' has no effect.
* All PolyCollection kwargs are valid, in the sense that they
will be passed on to the PolyCollection constructor.
In particular, one might want to use, for example:
linewidths = (1,), edgecolors = ('g',)
to make the arrows have green outlines of unit width.
- draw(self, renderer)
- set_UVC(self, U, V, C=None)
Data and other attributes defined here:
- quiver_doc = '\nPlot a 2-D field of arrows.\n\nFunction signature...e the arrows have green outlines of unit width.\n\n'
Methods inherited from matplotlib.collections.PolyCollection:
- get_verts(self, dataTrans=None)
- Return vertices in data coordinates.
The calculation is incomplete in general; it is based
on the vertices or the offsets, whichever is using
dataTrans as its transformation, so it does not take
into account the combined effect of segments and offsets.
- set_verts(self, verts)
- This allows one to delay initialization of the vertices.
Methods inherited from matplotlib.collections.PatchCollection:
- contains(self, mouseevent)
- Test whether the mouse event occurred in the collection.
Returns T/F, dict(ind=itemlist), where every item in itemlist contains the event.
- get_transformed_patches(self)
- get a sequence of the polygons in the collection in display (transformed) space
The ith element in the returned sequence is a list of x,y
vertices defining the ith polygon
- get_transoffset(self)
- set_alpha(self, alpha)
- Set the alpha tranpancies of the collection. Alpha must be
a float.
ACCEPTS: float
- set_color(self, c)
- Set both the edgecolor and the facecolor.
See set_facecolor and set_edgecolor.
ACCEPTS: matplotlib color arg or sequence of rgba tuples
- set_edgecolor(self, c)
- Set the edgecolor(s) of the collection. c can be a matplotlib color
arg (all patches have same color), or a 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_edgecolors(self, c)
- set_facecolor(self, c)
- Set the facecolor(s) of the collection. c can be a matplotlib
color arg (all patches have same color), or a 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_facecolors(self, c)
- set_linewidth(self, lw)
- 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_linewidths = set_linewidth(self, lw)
- 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_lw = set_linewidth(self, lw)
- 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
- update_scalarmappable(self)
- If the scalar mappable array is not none, update facecolors
from scalar data
Data and other attributes inherited from matplotlib.collections.PatchCollection:
- zorder = 1
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert x using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert y using yaxis unit type
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_axes(self)
- return the axes instance the artist resides in, or None
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or None for default.
- get_figure(self)
- return the figure instance
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return True if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- pick(mouseevent)
each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
- pickable(self)
- return True if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect will not
be visible until the figure is redrawn, e.g., with ax.draw_idle().
Call ax.relim() to update the axes limits if desired.
Note: relim() will not see collections even if the collection
was added to axes with autolim=True.
Note: there is no support for removing the artist's legend entry.
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_axes(self, axes)
- set the axes instance the artist resides in, if any
ACCEPTS: an axes instance
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path)
- Set the artist's clip path
ACCEPTS: an agg.path_storage instance
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event:
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return hit=True and props
is a dictionary of properties you want returned with the contains test.
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_picker(self, picker)
- set the epsilon for picking used by this artist
picker can be one of the following:
None - picking is disabled for this artist (default)
boolean - if True then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
float - if picker is a number it is interpreted as an
epsilon tolerance in points and the the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, eg the indices of the data within
epsilon of the pick event
function - if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event.
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return hit=True and props is a dictionary of
properties you want added to the PickEvent attributes
ACCEPTS: [None|float|boolean|callable]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
- update_from(self, other)
- copy properties from other to self
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
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.
- add_observer(self, mappable)
- whenever the norm, clim or cmap is set, call the notify
instance of the mappable observer with self.
This is designed to allow one image to follow changes in the
cmap of another image
- 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
- changed(self)
- Call this whenever the mappable is changed so observers can
update state
- 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
- notify(self, mappable)
- If this is called then we are pegged to another mappable.
Update our cmap, norm, alpha from the other mappable.
- 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.
|
class QuiverKey(matplotlib.artist.Artist) |
|
Labelled arrow for use as a quiver plot scale key. |
|
Methods defined here:
- __init__(self, Q, X, Y, U, label, **kw)
- Add a key to a quiver plot.
Function signature:
quiverkey(Q, X, Y, U, label, **kw)
Arguments:
Q is the Quiver instance returned by a call to quiver.
X, Y give the location of the key; additional explanation follows.
U is the length of the key
label is a string with the length and units of the key
Keyword arguments (default given first):
* coordinates = 'axes' | 'figure' | 'data' | 'inches'
Coordinate system and units for X, Y: 'axes' and 'figure'
are normalized coordinate systems with 0,0 in the lower
left and 1,1 in the upper right; 'data' are the axes
data coordinates (used for the locations of the vectors
in the quiver plot itself); 'inches' is position in the
figure in inches, with 0,0 at the lower left corner.
* color overrides face and edge colors from Q.
* labelpos = 'N' | 'S' | 'E' | 'W'
Position the label above, below, to the right, to the left
of the arrow, respectively.
* labelsep = 0.1 inches distance between the arrow and the label
* labelcolor (defaults to default Text color)
* fontproperties is a dictionary with keyword arguments accepted
by the FontProperties initializer: family, style, variant,
size, weight
Any additional keyword arguments are used to override vector
properties taken from Q.
The positioning of the key depends on X, Y, coordinates, and
labelpos. If labelpos is 'N' or 'S', X,Y give the position
of the middle of the key arrow. If labelpos is 'E', X,Y
positions the head, and if labelpos is 'W', X,Y positions the
tail; in either of these two cases, X,Y is somewhere in the middle
of the arrow+label key object.
- draw(self, renderer)
Data and other attributes defined here:
- halign = {'E': 'left', 'N': 'center', 'S': 'center', 'W': 'right'}
- pivot = {'E': 'tip', 'N': 'mid', 'S': 'mid', 'W': 'tail'}
- quiverkey_doc = '\nAdd a key to a quiver plot.\n\nFunction signature...in the middle\n of the arrow+label key object.\n'
- valign = {'E': 'center', 'N': 'bottom', 'S': 'top', 'W': 'center'}
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- contains(self, mouseevent)
- Test whether the artist contains the mouse event.
Returns the truth value and a dictionary of artist specific details of
selection, such as which points are contained in the pick radius. See
individual artists for details.
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert x using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert y using yaxis unit type
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_axes(self)
- return the axes instance the artist resides in, or None
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or None for default.
- get_figure(self)
- return the figure instance
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return True if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- pick(mouseevent)
each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
- pickable(self)
- return True if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect will not
be visible until the figure is redrawn, e.g., with ax.draw_idle().
Call ax.relim() to update the axes limits if desired.
Note: relim() will not see collections even if the collection
was added to axes with autolim=True.
Note: there is no support for removing the artist's legend entry.
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_axes(self, axes)
- set the axes instance the artist resides in, if any
ACCEPTS: an axes instance
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path)
- Set the artist's clip path
ACCEPTS: an agg.path_storage instance
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event:
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return hit=True and props
is a dictionary of properties you want returned with the contains test.
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_picker(self, picker)
- set the epsilon for picking used by this artist
picker can be one of the following:
None - picking is disabled for this artist (default)
boolean - if True then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
float - if picker is a number it is interpreted as an
epsilon tolerance in points and the the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, eg the indices of the data within
epsilon of the pick event
function - if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event.
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return hit=True and props is a dictionary of
properties you want added to the PickEvent attributes
ACCEPTS: [None|float|boolean|callable]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
- update_from(self, other)
- copy properties from other to self
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
| |