Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active November 3, 2020 17:25
Show Gist options
  • Save juanchiem/db7d4dd5f316cd02af92fdac5028fef5 to your computer and use it in GitHub Desktop.
Save juanchiem/db7d4dd5f316cd02af92fdac5028fef5 to your computer and use it in GitHub Desktop.
library(extrafont)
download.file("http://simonsoftware.se/other/xkcd.ttf",
dest="xkcd.ttf", mode="wb")
system("mkdir ~/.fonts")
system("cp xkcd.ttf ~/.fonts")
font_import(paths = "~/.fonts", pattern="[X/x]kcd")
fonts()
loadfonts()
ggplot(data.frame(x = c(0, 1)), aes(x = x)) +
stat_function(fun = dnorm, args = list(0.25, 0.1),
aes(colour = "Group 1"), size = 1.5) +
stat_function(fun = dnorm, args = list(0.7, 0.1),
aes(colour = "Group 2"), size = 1.5) +
scale_x_continuous(name = "Probability",
breaks = seq(0, 1, 0.2),
limits=c(0, 1)) +
scale_y_continuous(limits = c(0.01,4), name = "Frequency") +
ggtitle("Normal function curves of probabilities") +
scale_colour_brewer(palette="Set1") +
labs(colour = "Groups") +
theme(axis.line = element_line(size=1, colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
plot.title=element_text(size = 20, family="xkcd-Regular"),
text=element_text(size = 16, family="xkcd-Regular"),
axis.text.x=element_text(colour="black", size = 12),
axis.text.y=element_text(colour="black", size = 12))
@juanchiem
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment