GitHub

R-CMD-check

Installation

install.packages("hellokitty")

Or the development version

devtools::install_github("abigailkeller/hellokitty")

Palettes

library(hellokitty)

hellokitty contains two color palettes:

Hello Kitty Palette 1

Image Source

hkitty_palette("hellokitty1")

Hello Kitty Palette 2

Image Source

hkitty_palette("hellokitty2")

Example usage

The hellokitty package can be used to create both discrete and continuous color scales.

Example 1: Discrete color scale

First we will get data showing the number of Pacific salmon returning to the Columbia River Basin based on visual observations at Bonneville Dam.

library(tidyverse)
# get CRB salmon
salmon <- c("Chinook", "Chum", "Coho", "Pink", "Sockeye")
CRB_salmon <- CRB_long[CRB_long$Species %in% salmon, ]

We will then create a discrete color palette based on the different salmon species.

n_colors <- length(salmon)
pal1 <- hkitty_palette(name = "hellokitty2", n = n_colors, type = "discrete")

And we will plot the counts of salmon returns to Bonneville Dam over time:

ggplot(data = CRB_salmon) +
  geom_line(aes(x = year_label, y = total_value, color = Species)) +
  scale_color_manual(values = pal1) +
  labs(x = "Year", y = "Count", color = "Species") +
  ggtitle(paste0("Annual counts of salmon returns to Bonneville\nDam in the ",
                 "Columbia River Basin")) +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 14),
        legend.title = element_text(hjust = 0.5)
  )

Example 2: Continuous color scale

Now we will get a continuous color scale:

pal2 <- hkitty_palette(name = "hellokitty1", type = "continuous")

And use it to plot the relationship between the count of Chinook salmon, shad, and lamprey returning to the Columbia River:

ggplot(data = CRB_wide[CRB_wide$Lamprey > 0, ]) +
  geom_point(aes(x = log(Chinook), y = log(Shad), color = log(Lamprey))) +
  scale_color_gradientn(colors = pal2) +
  labs(x = "Chinook (log count)", y = "Shad (log count)",
       color = "Lamprey\n (log count)") +
  ggtitle("Fish co-occurrence in the Columbia River Basin") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 14),
        legend.title = element_text(hjust = 0.5)
  )

Notes

Code adapted from the wesanderson R package.

Read the original on github.com ↗