| |
- matplotlib.artist.Artist(__builtin__.object)
-
- Line2D
- VertexSelector
class Line2D(matplotlib.artist.Artist) |
| |
- Method resolution order:
- Line2D
- matplotlib.artist.Artist
- __builtin__.object
Methods defined here:
- __init__(self, xdata, ydata, linewidth=None, linestyle=None, color=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, **kwargs)
- Create a :class:`~matplotlib.lines.Line2D` instance with *x*
and *y* data in sequences *xdata*, *ydata*.
The kwargs are Line2D properties:
====================== ====================================================================================================
Property Description
====================== ====================================================================================================
alpha float
animated [True | False]
antialiased or aa [True | False]
axes unknown
clip_box a :class:`matplotlib.transform.Bbox` instance
clip_on [True | False]
clip_path a :class:`~matplotlib.path.Path` instance and a
color or c any matplotlib color
contains unknown
dash_capstyle ['butt' | 'round' | 'projecting']
dash_joinstyle ['miter' | 'round' | 'bevel']
dashes sequence of on/off ink in points
data (np.array xdata, np.array ydata)
figure a :class:`matplotlib.figure.Figure` instance
label any string
linestyle or ls [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
linewidth or lw float value in points
lod [True | False]
marker [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
markeredgecolor or mec any matplotlib color
markeredgewidth or mew float value in points
markerfacecolor or mfc any matplotlib color
markersize or ms float
picker unknown
pickradius unknown
solid_capstyle ['butt' | 'round' | 'projecting']
solid_joinstyle ['miter' | 'round' | 'bevel']
transform a matplotlib.transforms.Transform instance
visible [True | False]
xdata np.array
ydata np.array
zorder any number
====================== ====================================================================================================
- __str__(self)
- contains(self, mouseevent)
- Test whether the mouse event occurred on the line. The pick
radius determines the precision of the location test (usually
within five points of the value). Use
:meth:`~matplotlib.lines.Line2D.get_pickradius`/:meth:`~matplotlib.lines.Line2D.set_pickradius`
to view or modify it.
Returns *True* if any values are within the radius along with
``{'ind': pointlist}``, where *pointlist* is the set of points
within the radius.
TODO: sort returned indices by distance
- draw(self, renderer)
- get_aa(self)
- alias for get_antialiased
- get_antialiased(self)
- get_c(self)
- alias for get_color
- get_color(self)
- get_dash_capstyle(self)
- Get the cap style for dashed linestyles
- get_dash_joinstyle(self)
- Get the join style for dashed linestyles
- get_data(self, orig=True)
- Return the xdata, ydata.
If *orig* is *True*, return the original data
- get_linestyle(self)
- get_linewidth(self)
- get_ls(self)
- alias for get_linestyle
- get_lw(self)
- alias for get_linewidth
- get_marker(self)
- get_markeredgecolor(self)
- get_markeredgewidth(self)
- get_markerfacecolor(self)
- get_markersize(self)
- get_mec(self)
- alias for get_markeredgecolor
- get_mew(self)
- alias for get_markeredgewidth
- get_mfc(self)
- alias for get_markerfacecolor
- get_ms(self)
- alias for get_markersize
- get_path(self)
- Return the :class:`~matplotlib.path.Path` object associated
with this line.
- get_pickradius(self)
- return the pick radius used for containment tests
- get_solid_capstyle(self)
- Get the cap style for solid linestyles
- get_solid_joinstyle(self)
- Get the join style for solid linestyles
- get_window_extent(self, renderer)
- get_xdata(self, orig=True)
- Return the xdata.
If *orig* is *True*, return the original data, else the
processed data.
- get_xydata(self)
- Return the *xy* data as a Nx2 numpy array.
- get_ydata(self, orig=True)
- Return the ydata.
If *orig* is *True*, return the original data, else the
processed data.
- is_dashed(self)
- return True if line is dashstyle
- recache(self)
- set_aa(self, val)
- alias for set_antialiased
- set_antialiased(self, b)
- True if line should be drawin with antialiased rendering
ACCEPTS: [True | False]
- set_axes(self, ax)
- set_c(self, val)
- alias for set_color
- set_color(self, color)
- Set the color of the line
ACCEPTS: any matplotlib color
- set_dash_capstyle(self, s)
- Set the cap style for dashed linestyles
ACCEPTS: ['butt' | 'round' | 'projecting']
- set_dash_joinstyle(self, s)
- Set the join style for dashed linestyles
ACCEPTS: ['miter' | 'round' | 'bevel']
- set_dashes(self, seq)
- Set the dash sequence, sequence of dashes with on off ink in
points. If seq is empty or if seq = (None, None), the
linestyle will be set to solid.
ACCEPTS: sequence of on/off ink in points
- set_data(self, *args)
- Set the x and y data
ACCEPTS: (np.array xdata, np.array ydata)
- set_linestyle(self, linestyle)
- Set the linestyle of the line
'steps' is equivalent to 'steps-pre' and is maintained for
backward-compatibility.
ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
- set_linewidth(self, w)
- Set the line width in points
ACCEPTS: float value in points
- set_ls(self, val)
- alias for set_linestyle
- set_lw(self, val)
- alias for set_linewidth
- set_marker(self, marker)
- Set the line marker
ACCEPTS: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
| '<' | '>' | 'D' | 'H' | '^' | '_' | 'd'
| 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|'
| TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT
| 'None' | ' ' | '' ]
- set_markeredgecolor(self, ec)
- Set the marker edge color
ACCEPTS: any matplotlib color
- set_markeredgewidth(self, ew)
- Set the marker edge width in points
ACCEPTS: float value in points
- set_markerfacecolor(self, fc)
- Set the marker face color
ACCEPTS: any matplotlib color
- set_markersize(self, sz)
- Set the marker size in points
ACCEPTS: float
- set_mec(self, val)
- alias for set_markeredgecolor
- set_mew(self, val)
- alias for set_markeredgewidth
- set_mfc(self, val)
- alias for set_markerfacecolor
- set_ms(self, val)
- alias for set_markersize
- set_picker(self, p)
- Sets the event picker details for the line.
Accepts: float distance in points or callable pick function fn(artist,event)
- set_pickradius(self, d)
- Sets the pick radius used for containment tests
Accepts: float distance in points.
- set_solid_capstyle(self, s)
- Set the cap style for solid linestyles
ACCEPTS: ['butt' | 'round' | 'projecting']
- set_solid_joinstyle(self, s)
- Set the join style for solid linestyles
ACCEPTS: ['miter' | 'round' | 'bevel']
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transforms.Transform instance
- set_xdata(self, x)
- Set the data np.array for x
ACCEPTS: np.array
- set_ydata(self, y)
- Set the data np.array for y
ACCEPTS: np.array
- update_from(self, other)
- copy properties from other to self
Data and other attributes defined here:
- filled_markers = ('o', '^', 'v', '<', '>', 's', 'd', 'D', 'h', 'H', 'p')
- lineStyles = {'': '_draw_nothing', ' ': '_draw_nothing', '-': '_draw_solid', '--': '_draw_dashed', '-.': '_draw_dash_dot', ':': '_draw_dotted', 'None': '_draw_nothing', 'steps': '_draw_steps_pre', 'steps-mid': '_draw_steps_mid', 'steps-post': '_draw_steps_post', ...}
- markers = {0: '_draw_tickleft', 1: '_draw_tickright', 2: '_draw_tickup', 3: '_draw_tickdown', 4: '_draw_caretleft', 5: '_draw_caretright', 6: '_draw_caretup', 7: '_draw_caretdown', '': '_draw_nothing', ' ': '_draw_nothing', ...}
- validCap = ('butt', 'round', 'projecting')
- validJoin = ('miter', 'round', 'bevel')
- zorder = 2
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
- findobj(self, match=None)
- pyplot signature:
findobj(o=gcf(), match=None)
recursively find all :class:matplotlib.artist.Artist instances
contained in self
*match* can be
- None: return all objects contained in artist (including artist)
- function with signature ``boolean = match(artist)`` used to filter matches
- class instance: eg Line2D. Only return artists of class type
.. plot:: ../mpl_examples/pylab_examples/findobj_demo.py
- 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 :class:`~matplotlib.figure.Figure` instance the
artist belongs to.
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- Return the :class:`~matplotlib.transforms.Transform`
instance used by this artist.
- get_transformed_clip_path_and_affine(self)
- Return the clip path with the non-affine part of its
transformation applied, and the remaining affine part of its
transformation.
- 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)
- call signature::
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
:meth:`matplotlib.axes.Axes.draw_idle`. Call
:meth:`matplotlib.axes.Axes.relim` to update the axes limits
if desired.
Note: :meth:`~matplotlib.axes.Axes.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_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a :class:`matplotlib.transform.Bbox` instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path, transform=None)
- Set the artist's clip path, which may be:
* a :class:`~matplotlib.patches.Patch` (or subclass) instance
* a :class:`~matplotlib.path.Path` instance, in which case
an optional :class:`~matplotlib.transforms.Transform`
instance may be provided, which will be applied to the
path before using it for clipping.
* *None*, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to *None*.
ACCEPTS: a :class:`~matplotlib.path.Path` instance and a
:class:`~matplotlib.transforms.Transform` instance, a
:class:`~matplotlib.patches.Patch` instance, or *None*.
- 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 :class:`~matplotlib.figure.Figure` instance the artist
belongs to.
ACCEPTS: a :class:`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_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)
Data descriptors inherited from matplotlib.artist.Artist:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
|
class VertexSelector |
|
Manage the callbacks to maintain a list of selected vertices for
:class:`matplotlib.lines.Line2D`. Derived classes should override
:meth:`~matplotlib.lines.VertexSelector.process_selected` to do
something with the picks.
Here is an example which highlights the selected verts with red
circles::
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as lines
class HighlightSelected(lines.VertexSelector):
def __init__(self, line, fmt='ro', **kwargs):
lines.VertexSelector.__init__(self, line)
self.markers, = self.axes.plot([], [], fmt, **kwargs)
def process_selected(self, ind, xs, ys):
self.markers.set_data(xs, ys)
self.canvas.draw()
fig = plt.figure()
ax = fig.add_subplot(111)
x, y = np.random.rand(2, 30)
line, = ax.plot(x, y, 'bs-', picker=5)
selector = HighlightSelected(line)
plt.show() |
|
Methods defined here:
- __init__(self, line)
- Initialize the class with a :class:`matplotlib.lines.Line2D`
instance. The line should already be added to some
:class:`matplotlib.axes.Axes` instance and should have the
picker property set.
- onpick(self, event)
- When the line is picked, update the set of selected indicies.
- process_selected(self, ind, xs, ys)
- Default "do nothing" implementation of the
:meth:`process_selected` method.
*ind* are the indices of the selected vertices. *xs* and *ys*
are the coordinates of the selected vertices.
| |