Choose one or two of your previous plots, and give the scales a proper name.
Hint: Use one or more scale_...()
functions.
What happens if you call the same scale_...()
function twice in a plot?
Add an overview over all available colorblind friendly Brewer scales to your rmarkdown document.
Hint: Insert a code chunk containing RColorBrewer::display.brewer.all(colorblindFriendly = TRUE)
Choose an appealing scale for one of your plots that use the “color” or “fill” aesthetics. Apply it with scale_..._brewer("<name>", palette = "<palette>")
Hint: Use scale_..._distiller()
if you have mapped a continuous variable.
Practice Markdown: Create sections, subsections, item lists, emphasized and bold text, … .
Create a flipped boxplot of fuel economy by transmission type.
Plot highway vs. city fuel economy with an additional geom_abline()
layer. How do you set a 45° degree for the diagonal line?
Try to “estimate” an approximate ratio between the two economy measures by tweaking the slope
argument to geom_abline()
.
Choose your favorite among the predefined themes.
Hint: All start with theme_...()
, but watch out for theme_set()
.
Apply theme(legend.position = "bottom")
to a plot with a color or fill legend. What happens if you then apply theme_bw()
? Why?
Convert one of the scatterplots you generated previously using the following pattern:
p <-
data %>%
___ %>%
ggplot(aes(___)) +
geom_point()
plotly::ggplotly(p)
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)
Convert a bar plot or a histogram to plotly. How does this affect the tooltip?
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")
Show the quakes
data, or a subset, on a map:
library(leaflet)
quakes %>%
___ %>%
leaflet() %>%
addTiles() %>%
addCircles()
Add a popup to the tiles. Click on one of the circles
Hint: Use str_c()
or paste0()
to concatenate text and data.
library(leaflet)
___ %>%
addCircles()
Explore further options in ?addTiles
.
See section 4.2.3 in https://plotly-book.cpsievert.me/linking-views-without-shiny.html for linking a map to a plot.
Copyright © 2018 Kirill Müller. Licensed under CC BY-NC 4.0.