Color palettes for R data visualization based on the official school colors of the University of Pennsylvania.
Built by JRMA Maasch (2020).
Note: This package is not endorsed in any way by the University of Pennsylvania.
- About | License
- Usage | Installation | Documentation | Use with ggplot2 | Use with base R
- View demo plots | Classic palettes | Interpolated palettes
This package provides 13 color palettes based on the official school colors of the University of Pennsylvania. These color palettes are intended for data visualizations that must easily harmonize with Penn's official logo. Note: This package is not endorsed in any way by the University of Pennsylvania.
Two categories of palettes are provided: "classic" and "interpolated." Classic palettes adhere strictly to the official color values of the Penn logo. Interpolated palettes interpolate between the official Penn colors or between an official color value and white. For more information on the Penn logo, see https://branding.web-resources.upenn.edu/elements-penn-logo.
This package is licensed under the GNU General Public License v3.0 (GPL-3).
# Install development version.
# Note: the package devtools must be installed but need not be loaded.
devtools::install_github("jmaasch/pennR")
# Load package.
library(pennR)
Precede any function by a question mark to access description, arguments, return value, and usage suggestions. Vignette and further documentation coming soon.
# Access function documentation.
?penn()
All palettes are stored in the exported list penn_palettes
:
> names(penn_palettes)
[1] "Red" "Blue" "Red-Blue" "Red-Blue-White" "Blue 3"
[6] "Blue 5" "Blue 8" "Blue-Red 3" "Blue-Red 5" "Blue-Red 8"
[11] "Red 3" "Red 5" "Red 8"
To use a palette, pass the desired palette name as a string to penn()
:
my_palette <- penn("Blue 5")
Demo plots can be viewed by invoking the penn.demo()
and penn.demo.all()
functions.
penn.demo("Blue-Red 3")
penn.demo.all()
Hexadecimal color codes are accessible as shown below. Demo plots also feature hexadecimal legends for convenience. Hex values may be "cherry-picked" to create custom palettes.
> penn("Red 3")
[1] "#990000" "#C56F6F" "#E5BFBF"
The following reproducible example produces the plots below.
# Construct toy data.
set.seed(5)
df <- data.frame(Label = factor(rep(c("A", "B", "C"), each = 200)),
Value = round(c(rnorm(200, mean = 55, sd = 5),
rnorm(200, mean = 65, sd = 5),
rnorm(200, mean = 70, sd = 4))))
# Construct plot.
density <- ggplot(df,
aes(x = Value,
fill = Label)) +
geom_density(alpha = 0.9,
color = NA) +
theme_classic() +
theme(legend.position = "bottom",
legend.title = element_blank(),
axis.title = element_blank()) +
scale_x_continuous(expand = c(0, 0)) +
scale_fill_manual(values = penn("Blue-Red 3")) +
labs(title = "Blue-Red 3")
The following reproducible example produces the plot at right.
# Construct base R heatmap.
df <- scale(mtcars)
heatmap(df,
scale = "row",
col = penn("Blue 8"),
labRow = FALSE,
labCol = FALSE)