ggplot
master, watch this!A huge part of making a compelling and convincing plot is your choice of color and layout.
Your first video will take you through some great core principals of visualization. Then your two short readings will show you the basics of manipulating colors and themes in ggplot
.
The Glamour of Graphics - William Chase
Or, if you prefer to click through the slides, they are here.
jcolors
package for color palettesggthemer
package for setting universal themes.scale_color_continuous()
scale_color_discrete()
scale_fill_continuous()
scale_fill_discrete()
Consider the plot in Question 1. What change was made to it in each step below? That is, what code would go inside the function + theme( )
to produce the added change?
Which built-in theme is each of the following plots?
There are many, many ways to “spice up” your plots. We will focus in on one: making your plot animated!
The best package for this, if you are using ggplot
already, is gganimate
.
Note: gganimate
plot objects can sometimes take a long time to render. One way to make it quicker is to change the number of frames in your gif. Another trick is to use the cache chunk option in R Markdown, so that you don’t re-render the images every time you knit your file.
gganimate
at PlotCon 2016
Fill in the blanks for the following two gganimate
plots
<- oscars %>%
filter(Award_Gender != "Ungendered") %>%
ggplot(aes(y = Age_at_Award, x = award, fill = Award_Gender)) +
geom_boxplot() +
ggtitle("Age of Academy Award Winners ({ })") +
xlab("Year of Award") +
ylab("Age at Award") +
transition_ (Award_Gender) +
(alpha = 0.3)
animate(p1, = 10, = 5)
<- oscars %>%
filter(Award_Gender != "Ungendered") %>%
ggplot(aes(x = Age_at_Award, fill = Award_Gender)) +
geom_density(alpha = 0.5) +
ggtitle("Age of Academy Award Winners ({ }s)") +
xlab("Year of Award") +
ylab("Age at Award") +
(Decade_of_Award)
animate(p2, = 9, = 1)
Although we don’t have time to go in-depth on every single extension of ggplot
, there are so many wonderful ways to up your Data Viz game.
Take a look around the links below.
Which extension package would you use to… Hint: There is more than one possible answer for each question!