active {loon.ggplot}R Documentation

Modify the active component

Description

Set active and/or activeGeomLayers

Usage

active(active = NULL, activeGeomLayers = NULL)

Arguments

active

a logical or a logical vector of length n that determines which observations are active (TRUE and hence appear in the plot) and which are inactive (FALSE and hence do not appear). Default is TRUE.

activeGeomLayers

determine which geom layer is interactive by its 'geom_...' position in the grammar of the expression. Currently, only geom_point() and geom_histogram() can be set as the active geom layer(s) so far. (N.B. more than one geom_point() layer can be set as an active layer, but only one geom_histogram() can be set as an active geom layer and it can be the only active layer.)

Value

a ggproto object

See Also

linking, selection, zoom, hover, interactivity

Examples

if(interactive()) {

  # set active layer
  l_ggplot(mtcars, aes(mpg, wt, shape = factor(cyl))) +
    geom_point(colour = "black", size = 4.5) +
    geom_point(colour = "pink", size = 4) +
    geom_point(aes(shape = factor(cyl))) +
    # only show manual transmission cars
    # in the second interactive layer
    active(active = mtcars$am == 1,
           activeGeomLayers = 2)

  # Then, click the `reactivate` button on loon inspector
  # to display all interactive points
}

[Package loon.ggplot version 1.3.4 Index]