Skip to content

Instantly share code, notes, and snippets.

@rafapereirabr
Created July 4, 2020 19:02
Show Gist options
  • Save rafapereirabr/fd538ee7b40a1c680101ae4cd31b36ff to your computer and use it in GitHub Desktop.
Save rafapereirabr/fd538ee7b40a1c680101ae4cd31b36ff to your computer and use it in GitHub Desktop.

Color palette inspired by this gorgeous image of Mars landscape, captured by HiRISE (NASA) and processed by Seán Doran. I created this color scale with the help of Chroma.js Color Palette Helper.

Image credit: HiRISE & Seán Doran
library(ggplot2)
library(hexbin)
library(cowplot)
library(chroma)

# color palettes
chroma::show_col(interp_colors(25, colors=c("#3a5251",  "#d5b087"), interp="bezier"))
chroma::show_col(interp_colors(25, colors=c("#19323b", "#d5b087"), interp="bezier"))

# plot
green_ish <- ggplot(data.frame(x = rnorm(100000), y = rnorm(100000)), aes(x = x, y = y)) +
              geom_hex() + coord_fixed() + theme_void() +
              scale_fill_gradient(space = "Lab", 
                                  low = "#273e3d",
                                  high = "#d5b087")

blue_ish <- ggplot(data.frame(x = rnorm(100000), y = rnorm(100000)), aes(x = x, y = y)) +
              geom_hex() + coord_fixed() + theme_void() +
              scale_fill_gradient(space = "Lab", 
                                  low = "#19323b",
                                  high = "#d5b087") 

cowplot::plot_grid(green_ish, blue_ish)
@rafapereirabr
Copy link
Author

mars_landscape_urbandemographics

@rafapereirabr
Copy link
Author

mars-landscape-palette

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment