Created
March 18, 2015 15:58
-
-
Save tomhopper/ab5569cd84b071bd8097 to your computer and use it in GitHub Desktop.
Use the font Humor Sans instead of font xkcd with theme_xkcd()
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
# The xkcd font used by the package xkcd (which provides a theme for ggplot2) | |
# is missing many characters and some characters don't seem to display correctly. | |
# An alternate xkcd-style font is Humor Sans, available free from | |
# \url{http://antiyawn.com/uploads/humorsans.html} | |
# The code below forces the use of Humor Sans instead of xkcd. | |
# The xkcd and ggplot2 packages are available from CRAN. | |
library(ggplot2) | |
library(xkcd) | |
# Set up some data for plotting | |
temp_data2 <- data.frame( | |
gap = rep(c(16, 32, 64), each = 2), | |
eff = runif(3*2)) | |
# Create a ggplot2 scatterplot. The slashes (/) in the | |
# axis labels do not print correctly using font xkcd, | |
# but display when using Humor Sans | |
ggplot(temp_data2, aes(x = gap, y = eff)) + | |
geom_point() + | |
ylab("efficiency / %/100") + | |
xlab("disk gap / 1/64 inch") + | |
theme_xkcd() + | |
theme(text = element_text(size = 16, family = "Humor Sans")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment