The goal of usaidplot is to apply USAID’s color palette to ggplot2 graphs. This package is based on the USAID graphic standards manual and inspired by the BBC’s plotting package, bbplot. Special thanks to sheitin for helping get this thing off of my computer and into the world.
You can install the development version of usaidplot like so:
# install.packages("devtools")
::install_github("jacobpstein/usaidplot") devtools
Or the CRAN version using:
install.packages(usaidplot)
One neat thing about this package is that you can apply the USAID color palette to either discrete or continuous data without much effort.
Let’s look at a continuous example first using R’s mtcars data. We
specify data_type="continous"
to apply USAID’s color
palette to continuous data.
library(usaidplot)
library(ggplot2)
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(aes(fill = gear), shape = 21, stroke = 1, col = "white", size = 6) +
usaid_plot(data_type = "continuous")
Now, let’s make the same plot, but apply discrete colors using
data_type="discrete"
, which is also the default.
# we'll make gear a factor to change it from continous to discrete
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(aes(fill = factor(gear)), shape = 21, stroke = 1, col = "white", size = 6) +
usaid_plot(data_type = "discrete") # you can also just leave this blank
USAID’s PowerPoint presentation template has a grey
background. In some cases, users may want to avoid the white-grey
contrast when they import figures into this template. Using the
ppt=TRUE
option changes the background for all figures to
match the USAID slide template. The default is
ppt=FALSE
.
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(aes(fill = gear), shape = 21, stroke = 1, col = "white", size = 6) +
usaid_plot(data_type = "continuous", ppt = TRUE)
USAID’s branding standards suggest Gill Sans as the default font for
all publications. However, users will find that Gill Sans MT is a
Windows font, whereas the Mac equivalent is Gill Sans. This package
quietly runs a Sys.info()
function to determine what
operating system the user has and then changes the font accordingly to
avoid generating errors and to ease switching from one matchine to
another.