SkillAgentSearch skills...

UsydColours

University of Sydney colour palettes for ggplot2

Install / Use

/learn @Sydney-Informatics-Hub/UsydColours
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

usydColours

The University of Sydney colour palettes

The usydColours package is intended to provide a set of colour palettes for use with ggplot2 and plot graphs. The palettes have been derived from The University of Sydney Branding Document V2.0, and include the primary branding palette as well as some novelty palettes that capture the spirit and landmarks of the University.

For more information on University branding, refer to the following links:
* https://intranet.sydney.edu.au/services/marketing-communications/our-brand.html
* https://intranet.sydney.edu.au/content/dam/intranet/documents/services/marketing-communications/brand-documents/LR_Brand_Guidelines_V2.1_General.pdf

The functionality of usydColours is based on the wonderful wesanderson package (https://github.com/karthik/wesanderson).

Python equivalent

FYI For Python equivalent, see Luke Thompson's USyd-colours pypi package: https://pypi.org/project/usyd-colors/

Installation

library(devtools)

install_github("Sydney-Informatics-Hub/usydColours")

Usage

Below is a list of the currently available palettes.

##  [1] "modern"                "modern_extended"       "modern_tertiary"      
##  [4] "primary"               "modern_diverging"      "extended"             
##  [7] "secondary"             "pastel"                "complementary_ReGr"   
## [10] "complementary_ReBl"    "bright"                "muted"                
## [13] "trafficlight"          "heatmap"               "flametree"            
## [16] "jacaranda"             "harbour"               "sandstone"            
## [19] "ochre"                 "greyscale"             "BlGrYe"               
## [22] "BlOr"                  "diverging_blue_red"    "diverging_blue_orange"

Qualitative palettes

# Modern
util_visualise_pal(usyd_palettes[["modern"]])
<img src="README_files/figure-gfm/palettes_qualitative-1.png" style="display: block; margin: auto;" />
# Modern Extended
util_visualise_pal(usyd_palettes[["modern_extended"]])
<img src="README_files/figure-gfm/palettes_qualitative-2.png" style="display: block; margin: auto;" />
# Modern Tertiary
util_visualise_pal(usyd_palettes[["modern_tertiary"]])
<img src="README_files/figure-gfm/palettes_qualitative-3.png" style="display: block; margin: auto;" />
# Primary
util_visualise_pal(usyd_palettes[["primary"]])
<img src="README_files/figure-gfm/palettes_qualitative-4.png" style="display: block; margin: auto;" />
# Extended
util_visualise_pal(usyd_palettes[["extended"]])
<img src="README_files/figure-gfm/palettes_qualitative-5.png" style="display: block; margin: auto;" />
# Secondary
util_visualise_pal(usyd_palettes[["secondary"]])
<img src="README_files/figure-gfm/palettes_qualitative-6.png" style="display: block; margin: auto;" />
# Pastel
util_visualise_pal(usyd_palettes[["pastel"]])
<img src="README_files/figure-gfm/palettes_qualitative-7.png" style="display: block; margin: auto;" />
# Bright
util_visualise_pal(usyd_palettes[["bright"]])
<img src="README_files/figure-gfm/palettes_qualitative-8.png" style="display: block; margin: auto;" />

Sequential palettes

# Flame tree
util_visualise_pal(usyd_palettes[["flametree"]])
<img src="README_files/figure-gfm/palettes_sequential-1.png" style="display: block; margin: auto;" />
# Jacaranda
util_visualise_pal(usyd_palettes[["jacaranda"]])
<img src="README_files/figure-gfm/palettes_sequential-2.png" style="display: block; margin: auto;" />
# Sandstone
util_visualise_pal(usyd_palettes[["sandstone"]])
<img src="README_files/figure-gfm/palettes_sequential-3.png" style="display: block; margin: auto;" />
# Harbour
util_visualise_pal(usyd_palettes[["harbour"]])
<img src="README_files/figure-gfm/palettes_sequential-4.png" style="display: block; margin: auto;" />
# Ochre
util_visualise_pal(usyd_palettes[["ochre"]])
<img src="README_files/figure-gfm/palettes_sequential-5.png" style="display: block; margin: auto;" />
# Greyscale
util_visualise_pal(usyd_palettes[["greyscale"]])
<img src="README_files/figure-gfm/palettes_sequential-6.png" style="display: block; margin: auto;" />

Diverging palettes

# Modern (red/green)
util_visualise_pal(usyd_palettes[["modern_diverging"]])
<img src="README_files/figure-gfm/palettes_diverging-1.png" style="display: block; margin: auto;" />
# Complementary (red/green)
util_visualise_pal(usyd_palettes[["complementary_ReGr"]])
<img src="README_files/figure-gfm/palettes_diverging-2.png" style="display: block; margin: auto;" />
# Complementary (red/blue)
util_visualise_pal(usyd_palettes[["complementary_ReBl"]])
<img src="README_files/figure-gfm/palettes_diverging-3.png" style="display: block; margin: auto;" />
# Muted
util_visualise_pal(usyd_palettes[["muted"]])
<img src="README_files/figure-gfm/palettes_diverging-4.png" style="display: block; margin: auto;" />
# Traffic light
util_visualise_pal(usyd_palettes[["trafficlight"]])
<img src="README_files/figure-gfm/palettes_diverging-5.png" style="display: block; margin: auto;" />
# Diverging (blue/red)
util_visualise_pal(usyd_palettes[["diverging_blue_red"]])
<img src="README_files/figure-gfm/palettes_diverging-6.png" style="display: block; margin: auto;" />
# Diverging (blue/orange)
util_visualise_pal(usyd_palettes[["diverging_blue_orange"]])
<img src="README_files/figure-gfm/palettes_diverging-7.png" style="display: block; margin: auto;" />

Use with ggplot2

Below are some examples of usydColours in action.

Categorical data

# Bar graph with the tertiary palette
diamonds %>%
  filter(price < 1000) %>%
  ggplot(aes(price, fill = cut)) +
    geom_histogram(colour = "black", position = "dodge", binwidth = 250) +
    theme_bw() +
    scale_fill_manual(values = usyd_palette("modern_tertiary"))
<img src="README_files/figure-gfm/usage_categorical-1.png" style="display: block; margin: auto;" />
# Density graph with the muted palette
iris %>%
  ggplot(aes(x = Sepal.Length, fill = Species)) + 
    geom_density() +
    theme_bw() +
    facet_wrap(. ~ Species) +
    scale_fill_manual(values = usyd_palette("muted")) 
<img src="README_files/figure-gfm/usage_categorical-2.png" style="display: block; margin: auto;" />
# Scatter plot using the jacaranda palette
diamonds %>%
  filter(row_number() %% 5 == 1) %>%
  filter(carat < 3) %>%
  filter(clarity %in% c("SI2", "SI1", "VS2", "VVS2")) %>%
  ggplot(aes(carat, price, colour = clarity)) +
    geom_jitter(alpha = 0.7) +
    theme_bw() +
    scale_colour_manual(values = usyd_palette("jacaranda"))
<img src="README_files/figure-gfm/usage_categorical-3.png" style="display: block; margin: auto;" />

Continuous data

Use usyd_palette to interpolate colours between the discrete colours of the available palettes for continuous data. Remember to supply values for n and set type = "continuous".

Tip: you can also use usyd_palette to generate more colours of your favourite palette for categorical plots too!

# Heatmap
mpg %>%
  count(class, drv) %>%
  complete(class, drv, fill = list(n = 0L)) %>%
  ggplot(aes(x = class, y = drv)) +
  geom_tile(mapping = aes(fill = n)) +
  theme_bw() +
  scale_fill_gradientn(colours = usyd_palette("flametree", 100, type = "continuous"))
<img src="README_files/figure-gfm/usage_continuous1-1.png" style="display: block; margin: auto;" />
library(maps)
library(mapproj)

# Chloropleth
# This example is from: https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
unemp <- read.csv("http://datasets.flowingdata.com/unemployment09.csv",
                  header = FALSE, stringsAsFactors = FALSE)
names(unemp) <- c("id", "state_fips", "county_fips", "name", "year",
                  "?", "?", "?", "rate")
unemp$county <- tolower(gsub(" County, [A-Z]{2}", "", unemp$name))
unemp$county <- gsub("^(.*) parish, ..$","\\1", unemp$county)
unemp$state <- gsub("^.*([A-Z]{2}).*$", "\\1", unemp$name)

county_df <- map_data("county", projection = "albers", parameters = c(39, 45))
names(county_df) <- c("long", "lat", "group", "order", "state_name", "county")
county_df$state <- state.abb[match(county_df$state_name, tolower(state.name))]
county_df$state_name <- NULL

state_df <- map_data("state", projection = "albers", parameters = c(39, 45))

choropleth <- merge(county_df, unemp, by = c("state", "county"))
choropleth <- choropleth[order(choropleth$order), ]


ggplot(choropleth, aes(long, lat, group = group)) +
  geom_polygon(aes(fill = rate), colour = alpha("white", 1 / 2), size = 0.2) +
  geom_polygon(data = state_df, colour = "white", fill = NA) +
  coord_fixed() +
  theme_void() +
  ggtitle("US unemployment rate by county") +
  theme(axis.line = element_blank(), axis.text = element_blank(),
        axis.ticks = element_blank(), axis.title = element_blank()) +
  scale_fill_gradientn(colours = usyd_palette("modern_tertiary", 100, type = "continuous"))
<img src="README_files/figure-gfm/usage_continuous2-1.png" style="display: block; margin: auto;" />

Defining custom palettes

Want to make your own palette? No problem! You can also define your own palette by selecting colours of your choice with usyd_pal_gen.

Below is the full list of colour names contained in usydColours.

<img src="README_files/figure-gfm/swatchplot-1.png" style="display: block; margin: auto;" />

After you’ve decided on what colours you want, use usyd_pal_gen as shown below to make a custom palette.

# Define a new palette
my_palette <- usyd_pal_gen(
  "UpdatedOchre", 
  "LightOchre", 
  "NeutralGrey", 
  "Eucalypt", 
  "DarkEucalypt") 

# Use the new palette
diamonds %>%
  filter(price < 1000) %>%
  ggplot(
View on GitHub
GitHub Stars15
CategoryDevelopment
Updated1mo ago
Forks2

Languages

R

Security Score

75/100

Audited on Feb 22, 2026

No findings