# NOT RUN {
if(interactive()) {
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
g <- ggplot2loon(p)
# tkLabels
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
colour = factor(gear))) + facet_wrap(~am)
g1 <- ggplot2loon(p)
g2 <- ggplot2loon(p, tkLabels = FALSE)
}
# }
# NOT RUN {
df <- data.frame(
x = rnorm(120, c(0, 2, 4)),
y = rnorm(120, c(1, 2, 1)),
z = letters[1:3]
)
df2 <- dplyr::select(df, -z)
scatterplots <- ggplot(df, aes(x, y)) +
geom_point(data = df2, colour = "grey70") +
geom_point(aes(colour = z)) +
facet_wrap(~z)
# We can select the first geom_point layer to be
# the active layer as in
suppressWarnings(
lp_scatterplots_active1 <- ggplot2loon(scatterplots,
activeGeomLayers = 1,
linkingGroup = "test")
)
# Here the grey points are linked (not the coloured ones)
# We can select the second geom_point layer to be
# the active layer as in
lp_scatterplots_active2 <- ggplot2loon(scatterplots, activeGeomLayers = 2)
# Here the colour points are linked
# We can also select the both geom_point layers to be
# the active layer as in
suppressWarnings(
lp_scatterplots_active12 <- ggplot2loon(scatterplots, activeGeomLayers = c(1,2))
)
# Here the colour points and grey points are both linked
########### ggmatrix to loon ###########
pm <- GGally::ggpairs(iris, column = 1:4, ggplot2::aes(colour=Species))
lg <- ggplot2loon(pm)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab