Learn R Programming

loon.ggplot (version 1.1.0)

interactivity: Modify the interactivity component

Description

Set interactive components (e.g. linking, selecting, itemLabel, etc)

Usage

interactivity(
  linkingGroup = NULL,
  linkingKey = NULL,
  linkedStates = NULL,
  sync = NULL,
  activeGeomLayers = NULL,
  selected = NULL,
  selectBy = NULL,
  selectionLogic = NULL,
  itemLabel = NULL,
  showItemLabels = NULL,
  ...
)

Arguments

linkingGroup

A character. Plots only in the same linkingGroup can be linked

linkingKey

LinkingKey is the key of linking. Each object in one plot has a unique linking key. Elements in different plots are linked if they share the same linking keys.

linkedStates

The states to be linked. It can be "color", "selected", "active", "size" and "glyph" for a `l_plot` object and "color", "selected", "active" for a `l_hist` object.

sync

The way to synchronize several linked plots. It can be either "pull" (default) or "push". If the sync is "pull", the linked states (aesthetics attributes, e.g. "color", "selected", ...) of the new plot will be pulled from the linked plots; if the sync is "push", the linked states of the new plot will be pushed to the linked plots.

activeGeomLayers

determine which geom layer is interactive. Only geom_point() and geom_histogram() can be set as active geom layer(s) so far. (Notice, more than one geom_point() layers can be set as active layers, but only one geom_histogram() can be set as an active geom layer)

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.

itemLabel

The customized querying information.

showItemLabels

A logical value. Show item labels or not. Default is FALSE

...

named arguments to modify loon plot states. See l_info_states

Value

a ggproto object

Details

In interactive graphics, there are several fundamental infrastructures, such as querying, linking and selecting. Component interactivity is used to set these features.

Interactivity Description Subfunction
Linking Linking several plots to discover the pattern of interest linking
Selecting Highlight the subset of interest selecting
ItemLabel Querying in interactive graphics itemLabel

Examples

Run this code
# NOT RUN {
if(interactive()) {
  # Modify the 'linkingGroup' and 'origin' of a hist object
  l_ggplot(mtcars, mapping = aes(x = wt)) +
    geom_histogram() +
    interactivity(linkingGroup = "mt", origin = 2)
  # linking with the histogram
  l_ggplot(mtcars, mapping = aes(x = wt, y = hp)) +
    geom_point(size = 4) +
    interactivity(linkingGroup = "mt") +
    facet_wrap(~cyl)
}
# }

Run the code above in your browser using DataLab