Learn R Programming

loon.ggplot (version 1.1.0)

selecting: Modify the selecting component

Description

In interactive graphics, selecting is one of the most fundamental tool and used to highlight the subset of interest

Usage

selecting(selected = NULL, selectBy = NULL, selectionLogic = NULL)

Arguments

selected

A logical vector. If it is set as TRUE, the elements are highlighted as the graphics are constructed. Default is FALSE

selectBy

Select by "sweeping" (default) or "brushing".

selectionLogic

Selection logic. One of "select" (default), "deselect" and "invert". See details.

Value

a ggproto object

Details

There are two ways to directly select elements on the scatterplot using the mouse: either by "sweep" or by "brushing". "Sweeping" allows us to sweep out a contiguous area of the plot, while, in "brushing", the area is always fixed during the selection.

The selection logic give users more flexibility that users cannot only highlight the elements, but also can delight or invert (the highlighted to delighted, vice verse) the elements.

See Also

linking, itemLabel, interactivity

Examples

Run this code
# NOT RUN {
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
    selecting(selected = fourGear)
}
# }

Run the code above in your browser using DataLab