Skip to content

R package for applying State of Minnesota branding

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

jfangmeier/mnbrand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mnbrand

The goal of mnbrand is to make it easier to implement the official State of Minnesota color palette in ggplot2. This package also includes a theme function for flextable to create tables in R Markdown for Word and PowerPoint. Future versions of this package will include other functions/templates to implement the State of Minnesota branding in reports and other data products.

Installation

You can install the development version of mnbrand from GitHub with:

# install.packages("devtools")
devtools::install_github("jfangmeier/mnbrand")

Available Colors

The full list of brand colors is available with the show_palette_mn function.

library(mnbrand)

show_palette_mn()

Plot Examples

The mnbrand package can apply discrete palette colors (up to 10 colors) and continuous palette colors in ggplot2, depending on the variables being plotted. Here is an example using discrete colors with the scale_color_mn_d function:

library(ggplot2)

mtcars %>%
  ggplot(aes(x = mpg, y = hp, color = as.factor(carb))) +
  geom_point(size = 4) +
  scale_color_mn_d() +
  theme_minimal()

When plotting with continuous variables, you can specify whether the continuous palette should be diverting and what value should be used as the diverging point. You can also specify which colors to use for continuous palettes. Here is an example without diverging with the scale_fill_mn_c function:

library(tigris)
#> To enable 
#> caching of data, set `options(tigris_use_cache = TRUE)` in your R script or .Rprofile.
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

# download county boundaries with tigris package
mn_counties <- counties(state = "MN", progress_bar = FALSE)

# calculate share of area covered by water
mn_counties_pct_water <- 
  mn_counties %>% 
  transmute(WATER = AWATER / (AWATER + ALAND))

mn_counties_pct_water %>% 
  ggplot(aes(fill = WATER)) +
  geom_sf() +
  scale_fill_mn_c() +
  theme_minimal() +
  labs(title = "Share of County Covered by Water")

Here is an example with diverging colors with a specified diverging point and colors:

mn_counties_pct_water %>% 
  ggplot(aes(fill = WATER)) +
  geom_sf() +
  scale_fill_mn_c(
    diverge = TRUE,
    high_color = "minnesota_blue",
    low_color = "accent_orange",
    midpoint = 0.2
  ) +
  theme_minimal() +
  labs(title = "Share of County Covered by Water")

About

R package for applying State of Minnesota branding

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages