selection {loon.ggplot} | R Documentation |
Modify the selected
component
Description
Set which elements (i.e., observations) are "selected". These will be shown as highlighted in the
plot using the current "highlight" colour (see l_userOptions
).
Usage
selection(selected = NULL, selectBy = NULL, selectionLogic = NULL)
Arguments
selected |
a logical or a logical vector of length |
selectBy |
A string determining how selection will occur in the interactive plot.
Default is |
selectionLogic |
One of "select" (the default), "deselect", and "invert". The first highlights observations as selected, the second downlights them, and the third inverts them (downlighting highlit observations and highlighting downlighted ones). |
Details
There are two ways to directly select elements on, for example, a scatterplot using the mouse: either by "sweeping" or by "brushing". "Sweeping" allows us to sweep out a contiguous rectangular area of the plot, while, by "brushing", a fixed rectangular area is brushes across the plot selecting all points within the rectangle.
The selection logic give users more flexibility to users to not only highlight the elements, but also to downlight, and even to invert selections (changing the highlighted to downlighted, and vice versa).
Value
a ggproto
object
See Also
active
, linking
, zoom
,
hover
, interactivity
, l_userOptions
Examples
if(interactive()) {
# highlight the four gear cars
fourGear <- rep(FALSE, nrow(mtcars))
fourGear[mtcars$gear == 4] <- TRUE
l_ggplot(mtcars, mapping = aes(x = wt, y = hp, color = factor(cyl))) +
geom_point(size = 4) +
# push the states of scatter plot to the histogram
selection(selected = fourGear)
}