| |
- matplotlib.artist.Artist
-
- Legend
class Legend(matplotlib.artist.Artist) |
|
Place a legend on the axes at location loc. Labels are a
sequence of strings and loc can be a string or an integer
specifying the legend location
The location codes are
'best' : 0, (only implemented for axis legends)
'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4,
'right' : 5,
'center left' : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center' : 10,
Return value is a sequence of text, line instances that make
up the legend |
|
Methods defined here:
- __init__(self, parent, handles, labels, loc=None, numpoints=None, prop=None, pad=None, markerscale=None, labelsep=None, handlelen=None, handletextsep=None, axespad=None, shadow=None)
- parent # the artist that contains the legend
handles # a list of artists (lines, patches) to add to the legend
labels # a list of strings to label the legend
loc # a location code
numpoints = 4 # the number of points in the legend line
prop = FontProperties(size='smaller') # the font property
pad = 0.2 # the fractional whitespace inside the legend border
markerscale = 0.6 # the relative size of legend markers vs. original
shadow # if True, draw a shadow behind legend
The following dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
handlelen = 0.05 # the length of the legend lines
handletextsep = 0.02 # the space between the legend line and legend text
axespad = 0.02 # the border between the axes and legend edge
- __str__(self)
- draw(self, renderer)
- draw_frame(self, b)
- b is a boolean. Set draw frame to b
- get_frame(self)
- return the Rectangle instance used to frame the legend
- get_lines(self)
- return a list of lines.Line2D instances in the legend
- get_patches(self)
- return a list of patch instances in the legend
- get_texts(self)
- return a list of text.Text instance in the legend
- get_window_extent(self)
Data and other attributes defined here:
- codes = {'best': 0, 'center': 10, 'center left': 6, 'center right': 7, 'lower center': 8, 'lower left': 3, 'lower right': 4, 'right': 5, 'upper center': 9, 'upper left': 2, ...}
- zorder = 5
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'
| |