Giter Site home page Giter Site logo

jmaasch / pennr Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 4.16 MB

Color palettes for R data visualization based on the official school colors of the University of Pennsylvania.

R 100.00%
color-palettes pennsylvania upenn university-of-pennsylvania palettes colors colorschemes color-theme r data-visualizations data-visualization

pennr's Introduction

pennR

University of Pennsylvania Color Palettes

Color palettes for R data visualization based on the official school colors of the University of Pennsylvania.

density

Built by JRMA Maasch (2020).

Note: This package is not endorsed in any way by the University of Pennsylvania.

Table of contents

About

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.


License

This package is licensed under the GNU General Public License v3.0 (GPL-3).

return to top

Usage

Installation

# Install development version.
# Note: the package devtools must be installed but need not be loaded.
devtools::install_github("jmaasch/pennR")

# Load package.
library(pennR)

return to top

Documentation

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"

return to top

Use with ggplot2

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")

density2

return to top

Use with base R

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)

return to top

View demo plots

Classic palettes

classic

return to top

Interpolated palettes

interp

return to top

pennr's People

Contributors

jmaasch avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

watts-the-point

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.