linking {loon.ggplot} | R Documentation |
Modify the linking
component
Description
A group-key-state linking model is used to link plots in loon
. This allows changes in one plot
to propogate to all plots in the same linkingGroup
and enables interactive features like brushing.
Elements to be matched between plots are identified by linkingKey
; within each plot, the key for each
element (e.g., case, observation) is unique. The linkedStates
identify which display states (e.g., "color")
should change in concert with other plots in the linkingGroup
.
Usage
linking(
linkingGroup = NULL,
linkingKey = NULL,
linkedStates = NULL,
sync = NULL
)
Arguments
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 |
Value
a ggproto
object
See Also
active
, selection
, zoom
,
hover
, interactivity
,
l_getLinkedStates
, l_setLinkedStates
, l_configure
Examples
if(interactive() && requireNamespace("dplyr")) {
h <- l_hist(mtcars$hp,
linkingKey = rownames(mtcars),
linkingGroup = "mtcars")
mtcars %>%
mutate(carName = rownames(mtcars)) %>%
l_ggplot(mapping = aes(x = wt, y = hp, color = factor(cyl))) +
geom_point(size = 4) +
# push the states of scatter plot to the histogram
linking(linkingGroup = "mtcars",
linkingKey = ~carName,
sync = "push")
}