An R extension of the Python package vapeplot
's color palettes.
library(vapeplot) library(ggplot2) library(ggridges) library(gridExtra) knitr::opts_chunk$set(message = FALSE) knitr::opts_chunk$set(echo = FALSE) knitr::opts_chunk$set(fig.path = "man/figures/")
set.seed(3) x <- rnorm(500) y <- lapply(LETTERS[1:10], rep, times = 50) df <- data.frame(x = rev(sort(x)), y = rev(unlist(y))) p1 <- ggplot(df, aes(x = x, y = factor(y, levels = unique(y)))) + geom_density_ridges(aes(fill = y, color = rev(y))) + scale_fill_vapeplot_d(option = "jazzcup", guide = FALSE) + scale_color_vapeplot_d(option = "jazzcup", guide = FALSE) + labs(x = NULL, y = NULL) + scale_x_continuous(expand = c(0,0)) + scale_y_discrete(expand = c(0, 0)) + theme_minimal() + theme(panel.grid = element_blank())
p2 <- ggplot(faithfuld, aes(waiting, eruptions, z = density)) + geom_raster(aes(fill = density)) + scale_fill_vapeplot_c(option = "sunset") + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) + theme_minimal()
p3 <- ggplot(diamonds, aes(carat, ..count.., fill = cut)) + geom_density(position = "fill") + scale_fill_vapeplot_d(option = "cool") + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) + theme_minimal()
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests) crimesm <- reshape2::melt(crimes, id = 1) states_map <- map_data("state") p4 <- ggplot(subset(crimesm, variable == "Assault"), aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + scale_fill_vapeplot_c(option = "crystal_pepsi") + coord_fixed() + theme_void()
gridExtra::grid.arrange(p1, p2, p3, p4, ncol = 2)
show_palette()
library(vapeplot) library(ggplot2) ggplot(diamonds) + geom_point(aes(x = carat, y = price, color = cut)) + scale_color_vapeplot_d("mallsoft") ggplot(diamonds) + geom_bar(aes(x = cut, fill = clarity)) + scale_fill_vapeplot_d("seapunk")
ggplot(diamonds) + geom_point(aes(x = carat, y = price, color = cut), alpha = 0.7) + scale_color_vapeplot_d("mallsoft") + theme_classic() ggplot(diamonds) + geom_bar(aes(x = cut, fill = clarity)) + scale_fill_vapeplot_d("seapunk") + theme_classic() df <- data.frame(x = rnorm(500), y = rgamma(500, shape = 5, rate = 0.1)) ggplot(df) + geom_point(aes(x, y, color = y)) + scale_color_vapeplot_c() + theme_classic()
Design of this package drew on inspiration from ggplot2::scale_*_viridis_c()
and ggplot2::scale_*_viridis_d()
, and the nordic
package.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.