Interactions
bqplot.interacts
BrushIntervalSelector
Bases: OneDSelector
Brush interval selector interaction.
This 1-D selector interaction enables the user to select an interval using the brushing action of the mouse. A mouse-down marks the start of the interval. The drag after the mouse down in the x-direction selects the extent and a mouse-up signifies the end of the interval.
Once an interval is drawn, the selector can be moved to a new interval by dragging the selector to the new interval.
A double click at the same point without moving the mouse in the x-direction will result in the entire interval being selected.
ATTRIBUTE | DESCRIPTION |
---|---|
selected |
Two element array containing the start and end of the interval selected
in terms of the scale of the selector.
This attribute changes while the selection is being made with the
TYPE:
|
brushing |
Boolean attribute to indicate if the selector is being dragged. It is True when the selector is being moved and False when it is not. This attribute can be used to trigger computationally intensive code which should be run only on the interval selection being completed as opposed to code which should be run whenever selected is changing.
TYPE:
|
orientation |
The orientation of the interval, either vertical or horizontal
TYPE:
|
color |
Color of the rectangle representing the brush selector.
TYPE:
|
BrushSelector
Bases: TwoDSelector
Brush interval selector interaction.
This 2-D selector interaction enables the user to select a rectangular region using the brushing action of the mouse. A mouse-down marks the starting point of the interval. The drag after the mouse down selects the rectangle of interest and a mouse-up signifies the end point of the interval.
Once an interval is drawn, the selector can be moved to a new interval by dragging the selector to the new interval.
A double click at the same point without moving the mouse will result in the entire interval being selected.
ATTRIBUTE | DESCRIPTION |
---|---|
selected_x |
Two element array containing the start and end of the interval selected
in terms of the x_scale of the selector.
This attribute changes while the selection is being made with the
TYPE:
|
selected_y |
Two element array containing the start and end of the interval selected
in terms of the y_scale of the selector.
This attribute changes while the selection is being made with the
TYPE:
|
selected |
A 2x2 array containing the coordinates ::
TYPE:
|
brushing |
boolean attribute to indicate if the selector is being dragged. It is True when the selector is being moved and False when it is not. This attribute can be used to trigger computationally intensive code which should be run only on the interval selection being completed as opposed to code which should be run whenever selected is changing.
TYPE:
|
color |
Color of the rectangle representing the brush selector.
TYPE:
|
FastIntervalSelector
Bases: OneDSelector
Fast interval selector interaction.
This 1-D selector is used to select an interval on the x-scale by just moving the mouse (without clicking or dragging). The x-coordinate of the mouse controls the mid point of the interval selected while the y-coordinate of the mouse controls the the width of the interval. The larger the y-coordinate, the wider the interval selected.
Interval selector has three modes: 1. default mode: This is the default mode in which the mouse controls the location and width of the interval. 2. fixed-width mode: In this mode the width of the interval is frozen and only the location of the interval is controlled with the mouse. A single click from the default mode takes you to this mode. Another single click takes you back to the default mode. 3. frozen mode: In this mode the selected interval is frozen and the selector does not respond to mouse move. A double click from the default mode takes you to this mode. Another double click takes you back to the default mode.
ATTRIBUTE | DESCRIPTION |
---|---|
selected |
Two-element array containing the start and end of the interval selected in terms of the scale of the selector.
TYPE:
|
color |
color of the rectangle representing the interval selector
TYPE:
|
size |
if not None, this is the fixed pixel-width of the interval selector
TYPE:
|
HandDraw
Bases: Interaction
A hand-draw interaction.
This can be used to edit the 'y' value of an existing line using the mouse. The minimum and maximum x values of the line which can be edited may be passed as parameters. The y-values for any part of the line can be edited by drawing the desired path while holding the mouse-down. y-values corresponding to x-values smaller than min_x or greater than max_x cannot be edited by HandDraw.
ATTRIBUTE | DESCRIPTION |
---|---|
lines |
The instance of Lines which is edited using the hand-draw interaction. The 'y' values of the line are changed according to the path of the mouse. If the lines has multi dimensional 'y', then the 'line_index' attribute is used to selected the 'y' to be edited.
TYPE:
|
line_index |
For a line with multi-dimensional 'y', this indicates the index of the 'y' to be edited by the handdraw.
TYPE:
|
min_x |
The minimum value of 'x' which should be edited via the handdraw.
TYPE:
|
max_x |
The maximum value of 'x' which should be edited via the handdraw.
TYPE:
|
IndexSelector
Bases: OneDSelector
Index selector interaction.
This 1-D selector interaction uses the mouse x-coordinate to select the corresponding point in terms of the selector scale.
Index Selector has two modes: 1. default mode: The mouse controls the x-position of the selector. 2. frozen mode: In this mode, the selector is frozen at a point and does not respond to mouse events.
A single click switches between the two modes.
ATTRIBUTE | DESCRIPTION |
---|---|
selected |
A single element array containing the point corresponding the x-position of the mouse. This attribute is updated as you move the mouse along the x-direction on the figure.
TYPE:
|
color |
Color of the line representing the index selector.
TYPE:
|
line_width |
Width of the line representing the index selector.
TYPE:
|
Interaction
Bases: Widget
The base interaction class.
An interaction is a mouse interaction layer for a figure that requires the capture of all mouse events on the plot area. A consequence is that one can allow only one interaction at any time on a figure.
An interaction can be associated with features such as selection or manual change of specific mark. Although, they differ from the so called 'mark interactions' in that they do not rely on knowing whether a specific element of the mark are hovered by the mouse.
ATTRIBUTE | DESCRIPTION |
---|---|
types |
A registry of existing interaction types.
TYPE:
|
LassoSelector
Bases: TwoDSelector
Lasso selector interaction.
This 2-D selector enables the user to select multiple sets of data points
by drawing lassos on the figure. A mouse-down starts drawing the lasso and
after the mouse-up the lasso is closed and the selected
attribute of each
mark gets updated with the data in the lasso.
The user can select (de-select) by clicking on lassos and can delete them (and their associated data) by pressing the 'Delete' button.
ATTRIBUTE | DESCRIPTION |
---|---|
marks |
List of marks on which lasso selector will be applied.
TYPE:
|
color |
Color of the lasso.
TYPE:
|
MultiSelector
Bases: BrushIntervalSelector
Multi selector interaction.
This 1-D selector interaction enables the user to select multiple intervals using the mouse. A mouse-down marks the start of the interval. The drag after the mouse down in the x-direction selects the extent and a mouse-up signifies the end of the interval.
The current selector is highlighted with a green border and the inactive selectors are highlighted with a red border.
The multi selector has three modes: 1. default mode: In this mode the interaction behaves exactly as the brush selector interaction with the current selector. 2. add mode: In this mode a new selector can be added by clicking at a point and dragging over the interval of interest. Once a new selector has been added, the multi selector is back in the default mode. From the default mode, ctrl+click switches to the add mode. 3. choose mode: In this mode, any of the existing inactive selectors can be set as the active selector. When an inactive selector is selected by clicking, the multi selector goes back to the default mode. From the default mode, shift+click switches to the choose mode.
A double click at the same point without moving the mouse in the x-direction will result in the entire interval being selected for the current selector.
ATTRIBUTE | DESCRIPTION |
---|---|
selected |
A dictionary with keys being the names of the intervals and values being the two element arrays containing the start and end of the interval selected by that particular selector in terms of the scale of the selector. This is a read-only attribute. This attribute changes while the selection is being made with the MultiSelectorinteraction.
TYPE:
|
brushing |
A boolean attribute to indicate if the selector is being dragged. It is True when the selector is being moved and false when it is not. This attribute can be used to trigger computationally intensive code which should be run only on the interval selection being completed as opposed to code which should be run whenever selected is changing.
TYPE:
|
names |
A list of strings indicating the keys of the different intervals. Default values are 'int1', 'int2', 'int3' and so on.
TYPE:
|
show_names |
Attribute to indicate if the names of the intervals are to be displayed along with the interval.
TYPE:
|
OneDSelector
Bases: Selector
One-dimensional selector interaction
Base class for all selectors which select data in one dimension, i.e.,
either the x or the y direction. The scale
attribute should
be provided.
ATTRIBUTE | DESCRIPTION |
---|---|
scale |
This is the scale which is used for inversion from the pixels to data coordinates. This scale is used for setting the selected attribute for the selector.
TYPE:
|
PanZoom
Bases: Interaction
An interaction to pan and zoom wrt scales.
ATTRIBUTE | DESCRIPTION |
---|---|
allow_pan |
Toggle the ability to pan.
TYPE:
|
allow_zoom |
Toggle the ability to zoom.
TYPE:
|
scales |
Dictionary with keys such as 'x' and 'y' and values being the scales in the corresponding direction (dimensions) which should be panned or zoomed.
TYPE:
|
Selector
Bases: Interaction
Selector interaction. A selector can be used to select a subset of data
Base class for all the selectors.
ATTRIBUTE | DESCRIPTION |
---|---|
marks |
list of marks for which the
TYPE:
|
TwoDSelector
Bases: Selector
Two-dimensional selector interaction.
Base class for all selectors which select data in both the x and y dimensions. The attributes 'x_scale' and 'y_scale' should be provided.
ATTRIBUTE | DESCRIPTION |
---|---|
x_scale |
This is the scale which is used for inversion from the pixels to data
coordinates in the x-direction. This scale is used for setting the
selected attribute for the selector along with
TYPE:
|
y_scale |
This is the scale which is used for inversion from the pixels to data
coordinates in the y-direction. This scale is used for setting the
selected attribute for the selector along with
TYPE:
|
panzoom(marks)
Helper function for panning and zooming over a set of marks.
Creates and returns a panzoom interaction with the 'x' and 'y' dimension scales of the specified marks.