Created
May 17, 2016 18:08
-
-
Save AndrewTheTM/029ba367fd70d0475bc670291caa6977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xkcd) | |
library(ggplot2) | |
# Load the font from https://github.com/shreyankg/xkcd-desktop/blob/master/Humor-Sans.ttf | |
windowsFonts(HS=windowsFont("Humor Sans")) | |
airplaneSeats1 = data.frame(Width = pnorm(seq(0,1,0.025), mean = 0.5, sd = 0.1) * 10) | |
airplaneSeats1$label = "Avg American Width" | |
airplaneSeats1$time = as.integer(row.names(airplaneSeats1)) + 1975 | |
airplaneSeats2 = data.frame(Width = 50 - (pnorm(seq(0,1,0.025), mean = 0.5, sd = 0.1) * 50)) | |
airplaneSeats2$label = "Airplane Seat Width" | |
airplaneSeats2$time = as.integer(row.names(airplaneSeats2)) + 1975 | |
airplaneSeats = rbind(airplaneSeats1, airplaneSeats2) | |
### XKCD theme - from http://stackoverflow.com/a/12681845/877387 | |
theme_xkcd <- theme( | |
panel.background = element_rect(fill="white"), | |
axis.ticks = element_line(colour=NA), | |
panel.grid = element_line(colour="white"), | |
axis.text.y = element_text(colour=NA), | |
axis.text.x = element_text(colour="black"), | |
text = element_text(size=16, family="HS"), | |
axis.line = element_line(size = 1.2, colour = "black", position = position_jitter(width = 0.5, height = 0.5)) | |
) | |
plot = ggplot(airplaneSeats, aes(x = time, y = Width, color = label)) + | |
geom_line(position = position_jitter(width = 0.25, height = 0.15), size = 1.2 ) + | |
xlab("Year") + theme_xkcd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment