if(interactive()) {
p <- l_ggplot(mtcars,
mapping = aes(x = hp, y = mpg)) +
geom_point(mapping = aes(color = factor(gear))) +
geom_smooth(data = mtcars[mtcars$gear == 4, ],
method = "lm")
# a scatter plot with a fitted line on 4 gear cars
p
# scale to the second layer (smooth line)
p + zoom(layerId = 2)
# highlight the 3 gear cars
# scale to the selected points
p +
selection(mtcars$gear == 3) +
zoom(layerId = 1,
scaleToFun = loon::l_scaleto_selected)
}
Run the code above in your browser using DataLab