19 Programming with ggplot2

19.1 Exercises

1.

pink_hist <- geom_histogram(
  color = "pink",
  bins = 100
)


2.

fill_blues <- scale_fill_distiller(
  palette = "Blues"
)


3.

?theme_gray()
  • Its arguments include base_size, base_family, base_line_size, and base_rect_size
  • According to the help file, theme_gray() is the signature ggplot2 theme with a grey background and white gridlines and is designed to put the data forward yet make comparisons easy.


4.

scale_colour_wesanderson <- function(palette = "BottleRocket1", ...) {
  scale_color_manual(values = wesanderson::wes_palette(palette), ...) 
}

# Working example
ggplot(mtcars, aes(wt, disp, color = factor(gear))) +
  geom_point() +
  scale_colour_wesanderson()


19.2 Exercises

1.

remove_labels <- theme(legend.position = "none",
                       axis.title.x = element_blank(),
                       axis.title.y = element_blank())

# Working Example
ggplot(mtcars, aes(wt, disp, color = factor(gear))) +
  geom_point() +
  remove_labels


2. Not sure


19.3 Exercises

These questions are way above my head!

19.4 Exercises

These questions are way above my head!