Convert one of the scatterplots you generated previously using the following pattern:
p <-
data %>%
___ %>%
ggplot(aes(___)) +
geom_point()
plotly::ggplotly(p)
► Solution:
p <-
mpg %>%
ggplot(aes(x = displ, y = hwy, color = drv)) +
geom_jitter() +
geom_smooth()
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
Experiment with the plotly controls on the top right.
Add extra aesthetics to the scatterplot. Hover with the mouse over the points:
p <-
data %>%
___ %>%
ggplot(aes(___, extra1 = manufacturer, extra2 = model)) +
geom_point()
plotly::ggplotly(p)
► Solution:
p <-
mpg %>%
ggplot(aes(x = displ, y = hwy, extra1 = manufacturer, extra2 = model)) +
geom_jitter()
plotly::ggplotly(p)
Convert a bar plot or a histogram to plotly. How does this affect the tooltip?
► Solution:
p <-
mpg %>%
ggplot(aes(x = drv)) +
geom_bar()
plotly::ggplotly(p)
See https://plotly-book.cpsievert.me/linking-views-without-shiny.html for examples of linking two plots, or linking plots with other widgets. This requires the crosstalk package:
install.packages("crosstalk")
Copyright © 2018 Kirill Müller. Licensed under CC BY-NC 4.0.