cytoflow.utility.matplotlib_widgets¶
Additional widgets to be used with matplotlib
-
class
cytoflow.utility.matplotlib_widgets.
PolygonSelector
(ax, callback=None, useblit=True)[source]¶ Bases:
matplotlib.widgets.AxesWidget
Selection polygon.
The selected path can be used in conjunction with
contains_point()
to select data points from an image.Parameters: - ax (
Axes
) – The parent axes for the widget. - callback (callable) – When the user double-clicks, the polygon closes and the
callback
function is called and passed the vertices of the selected path.
- ax (
-
class
cytoflow.utility.matplotlib_widgets.
SpanSelector
(ax, onselect, minspan=None, useblit=False, onmove_callback=None, span_stays=False, button=None)[source]¶ Bases:
matplotlib.widgets._SelectorWidget
Adapted from https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/widgets.py
Visually select a min/max range on a single axis and call a function with those values.
To guarantee that the selector remains responsive, keep a reference to it. In order to turn off the SpanSelector, set span_selector.active=False. To turn it back on, set span_selector.active=True.
Parameters: ax (
matplotlib.axes.Axes
object)onselect (func(min, max), min/max are floats)
direction (“horizontal” or “vertical”) – The axis along which to draw the span selector
minspan (float, default is None) – If selection is less than minspan, do not call onselect
useblit (bool, default is False) – If True, use the backend-dependent blitting features for faster canvas updates.
onmove_callback (func(min, max), min/max are floats, default is None) – Called on mouse move while the span is being selected
span_stays (bool, default is False) – If True, the span stays visible after the mouse is released
button (int or list of ints) –
- Determines which mouse buttons activate the span selector
1 = left mouse button
2 = center mouse button (scroll wheel)
3 = right mouse button
Examples
>>> import matplotlib.pyplot as plt >>> import matplotlib.widgets as mwidgets >>> fig, ax = plt.subplots() >>> ax.plot([1, 2, 3], [10, 50, 100]) >>> def onselect(vmin, vmax): print(vmin, vmax) >>> span = mwidgets.SpanSelector(ax, onselect, 'horizontal') >>> fig.show() See also: :ref:`sphx_glr_gallery_widgets_span_selector.py`
-
class
cytoflow.utility.matplotlib_widgets.
Cursor
(ax, horizOn=True, vertOn=True, useblit=False, **lineprops)[source]¶ Bases:
matplotlib.widgets.AxesWidget
A horizontal and vertical line that spans the axes and moves with the pointer. You can turn off the hline or vline respectively with the following attributes:
- horizOn
- Controls the visibility of the horizontal line
- vertOn
- Controls the visibility of the horizontal line
and the visibility of the cursor itself with the visible attribute.
For the cursor to remain responsive you must keep a reference to it.
Adapted from https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/widgets.py