tinter
provides a simple way to generate monochromatic palettes.
Easily define:
steps
).crop = 1
eliminates black and white).adjust
).library(tinter)
hex <- "#335CAC"
tinter(hex)
#> [1] "#D6DEEE" "#ADBDDD" "#849DCD" "#5B7CBC" "#335CAC" "#284989" "#1E3767"
#> [8] "#142444" "#0A1222"
tinter(hex, direction = "tints")
tinter(hex, steps = 10)
tinter(hex, steps = 10, crop = 7)
tinter(hex, steps = 10, crop = 7, adjust = 0.4)
library(ggplot2)
library(sf)
nc <- st_read(system.file(package = "sf", "shape/nc.shp"))
ggplot(data = nc) +
geom_sf(aes(fill = AREA), colour = "white", lwd = 0.04) +
# colours from tinter
scale_fill_gradientn(colours = tinter(hex)) +
theme_void() +
coord_sf(datum = NA)
tinter
just simplifies a task usually done with grDevices
. It’s
default is to remove black and white from the palette.
tinter("blue")
#> [1] "#CCCCFF" "#9999FF" "#6666FF" "#3333FF" "#0000FF" "#0000CC" "#000099"
#> [8] "#000065" "#000032"
### ------ is identical to
grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1, 11))]
#> [1] "#CCCCFF" "#9999FF" "#6565FF" "#3232FF" "#0000FF" "#0000CB" "#000098"
#> [8] "#000065" "#000032"
tinter("blue", direction = "shades")
#> [1] "#0000FF" "#0000CC" "#000099" "#000065" "#000032"
### --- is identical to
grDevices::colorRampPalette(colors = c("blue", "black"))(6)[-6]
#> [1] "#0000FF" "#0000CC" "#000099" "#000065" "#000032"
tinter("blue", crop = 2)
#> [1] "#9999FF" "#6666FF" "#3333FF" "#0000FF" "#0000CC" "#000099" "#000065"
### --- is identical to
grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1:2, 10:11))]
#> [1] "#9999FF" "#6565FF" "#3232FF" "#0000FF" "#0000CB" "#000098" "#000065"
To install the latest release from CRAN
install.packages("tinter")
To install the developmental version from GitHub
# install.packages("remotes")
remotes::install_github("poissonconsulting/tinter")
To install the latest developmental release from the Poisson drat repository
# install.packages("drat")
drat::addRepo("poissonconsulting")
install.packages("tinter")
Please report any issues.
Pull requests are always welcome.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.