arbitragelab.util.data_cursor
Module Contents
Classes
A simple data cursor widget that displays the x,y location of a |
|
A data cursor that highlights the selected Line2D artist. |
Functions
|
Get information for a pick event on an |
|
Get information for a pick event on a Line2D artist (as created with |
|
Get information for a pick event on an artist collection (e.g. |
|
Get information for a pick event on a PathCollection artist (usually |
|
|
|
Get information for a pick event on a 3D artist. |
|
Returns the width, height, left, and bottom of a rectangle artist. |
|
Attempts to get the x,y data for individual items subitems of the artist. |
Attributes
- __license__ = Multiline-String
Show Value
""" Copyright (c) 2012 mpldatacursor developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """
- class DataCursor(artists, tolerance=5, formatter=None, point_labels=None, display='one-per-axes', draggable=False, hover=False, props_override=None, keybindings=True, date_format='%x %X', display_button=1, hide_button=3, keep_inside=True, **kwargs)
Bases:
object
A simple data cursor widget that displays the x,y location of a matplotlib artist in an annotation box when the artist is clicked on.
- default_annotation_kwargs
- default_keybindings
- enabled
- __call__(event)
Create or update annotations for the given event. (This is intended to be a callback connected to matplotlib’s pick event.)
- event_info(event)
Get a dict of info for the artist selected by “event”.
- annotate(ax, **kwargs)
Draws the annotation box for the given axis ax. Additional kwargs are passed on to
annotate
.
- hide()
Hides all annotation artists associated with the DataCursor. Returns self to allow “chaining”. (e.g.
datacursor.hide().disable()
)
- show()
Display all hidden data cursors. Returns self to allow chaining.
- disable()
Disconnects all callbacks and disables interactivity. Any existing annotations will continue to be visible (and draggable, if applicable). This has no effect if the datacursor has not been enabled. Returns self to allow “chaining”. (e.g.
datacursor.hide().disable()
)
- enable()
Connects callbacks and makes artists pickable. If the datacursor has already been enabled, this function has no effect.
- update(event, annotation)
Update the specified annotation.
- class HighlightingDataCursor(*args, **kwargs)
Bases:
DataCursor
A data cursor that highlights the selected Line2D artist.
- default_annotation_kwargs
- default_keybindings
- enabled
- update(event, annotation)
Update the specified annotation.
- show_highlight(artist)
Show or create a highlight for a givent artist.
- create_highlight(artist)
Create a new highlight for the given artist.
- __call__(event)
Create or update annotations for the given event. (This is intended to be a callback connected to matplotlib’s pick event.)
- event_info(event)
Get a dict of info for the artist selected by “event”.
- annotate(ax, **kwargs)
Draws the annotation box for the given axis ax. Additional kwargs are passed on to
annotate
.
- hide()
Hides all annotation artists associated with the DataCursor. Returns self to allow “chaining”. (e.g.
datacursor.hide().disable()
)
- show()
Display all hidden data cursors. Returns self to allow chaining.
- disable()
Disconnects all callbacks and disables interactivity. Any existing annotations will continue to be visible (and draggable, if applicable). This has no effect if the datacursor has not been enabled. Returns self to allow “chaining”. (e.g.
datacursor.hide().disable()
)
- enable()
Connects callbacks and makes artists pickable. If the datacursor has already been enabled, this function has no effect.
- image_props(event)
Get information for a pick event on an
AxesImage
artist. Returns a dict of “i” & “j” index values of the image for the point clicked, and “z”: the (uninterpolated) value of the image at i,j.Parameters
- eventPickEvent
The pick event to process
Returns
- propsdict
A dict with keys: z, i, j
- line_props(event)
Get information for a pick event on a Line2D artist (as created with
plot
.)This will yield x and y values that are interpolated between vertices (instead of just being the position of the mouse) or snapped to the nearest vertex if only the vertices are drawn.
Parameters
- eventPickEvent
The pick event to process
Returns
- propsdict
A dict with keys: x & y
- collection_props(event)
Get information for a pick event on an artist collection (e.g. LineCollection, PathCollection, PatchCollection, etc). This will
- scatter_props(event)
Get information for a pick event on a PathCollection artist (usually created with
scatter
).Parameters
- eventPickEvent
The pick event to process
Returns
- A dict with keys:
c: The value of the color array at the point clicked. s: The value of the size array at the point clicked. z: Identical to c. Specified for convenience.
Notes
If constant values were specified to
c
ors
when callingscatter
, c and/or z will beNone
.
- errorbar_props(event)
- three_dim_props(event)
Get information for a pick event on a 3D artist.
Parameters
- eventPickEvent
The pick event to process
Returns
- A dict with keys:
x: The estimated x-value of the click on the artist y: The estimated y-value of the click on the artist z: The estimated z-value of the click on the artist
Notes
Based on mpl_toolkits.axes3d.Axes3D.format_coord Many thanks to Ben Root for pointing this out!
- rectangle_props(event)
Returns the width, height, left, and bottom of a rectangle artist.
Parameters
- eventPickEvent
The pick event to process
Returns
- A dict with keys:
width : The width of the rectangle height : The height of the rectangle left : The minimum x-coordinate of the rectangle right : The maximum x-coordinate of the rectangle bottom : The minimum y-coordinate of the rectangle top : The maximum y-coordinate of the rectangle xcenter : The mean x-coordinate of the rectangle ycenter : The mean y-coordinate of the rectangle label : The label for the rectangle or None
- get_xy(artist)
Attempts to get the x,y data for individual items subitems of the artist. Returns None if this is not possible.
At present, this only supports Line2D’s and basic collections.