View source: R/interactive-ggproto.R
interactivity | R Documentation |
interactivity
componentSet interactive components (e.g. linking
, selection
, etc)
interactivity( linkingGroup = NULL, linkingKey = NULL, linkedStates = NULL, sync = NULL, active = NULL, activeGeomLayers = NULL, selected = NULL, selectBy = NULL, selectionLogic = NULL, layerId = NULL, scaleToFun = NULL, itemLabel = NULL, showItemLabels = NULL, ... )
linkingGroup |
The string identifying the group of linked plots that the current plot will join. Default is none. |
linkingKey |
The length |
linkedStates |
The character vector of display states to be linked. These can be "color", "selected", "active", "size" and "glyph" for an 'l_plot' object and "color", "selected", "active" for an 'l_hist' object. (These roughly correspond to aesthetics in a 'ggplot'.) |
sync |
Either |
active |
a logical or a logical vector of length |
activeGeomLayers |
determine which geom layer is interactive by its 'geom_...' position in the grammar of the expression.
Currently, only |
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). |
layerId |
numerical; which layer to scale to |
scaleToFun |
scale to function. See |
itemLabel |
A character vector of length |
showItemLabels |
A single logical value: |
... |
named arguments to modify |
In interactive graphics, there are several fundamental infrastructures, such as querying, linking and selection.
Component interactivity
is used to set these features.
Interactivity | Description | Subfunction |
Linking | Linking several plots to discover the pattern of interest | linking |
Selection | Highlight the subset of interest | selection |
Active | Determine which points appear | active |
Hover | Query in interactive graphics | hover |
Zoom | Region Modification | zoom |
a ggproto
object
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) p <- ggplot(economics_long, aes(value)) + facet_wrap(~variable, scales = 'free_x') + geom_histogram() # `p` is a ggplot object p # turn static `ggplot` to interactive `loon` p + interactivity() }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.