A package for creating monochrome colour palettes and easily converting rgba values to hex codes
License
Insights
cararthompson/monochromeR
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more .
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Failed to load latest commit information.
Type
View code
monochromeR: An easy way to create monochrome colour palettes
What does the package do?
This package generates a monochrome palette from a starting colour for a specified number of colours. Users can decide whether to go darker, lighter, or both ways from that starting colour, which can be provided as a vector of rgb values (e.g. c(15, 75, 99)), a hex colour code (e.g. #0F4B63) or a recognised colour name (e.g. "purple"). The package can also display the generated palette in the plot window, with or without hex colour code labels.
How can I use it?
This package is available on CRAN , so can be installed using install.packages("monochromeR").
Alternatively, to install it from here, use remotes::github_install("cararthompson/monochromeR"). (To do this, you need to have installed the remotes package. To do that, use install.packages("remotes").)
Can we see some examples?
Sure! Here goes. To make the examples easy to read, I will use recognised colour names rather than hex codes or rgb values.
Generate monochrome palettes with generate_palette()
library(monochromeR) generate_palette("purple", modification = "go_lighter", n_colours = 5, view_palette = TRUE)
## [1] "#A020F0" "#B34CF3" "#C679F6" "#D9A5F9" "#ECD2FC"
The functions allow for British spelling and US spelling of colour/color.
generate_palette("purple", modification = "go_darker", n_colors = 5, view_palette = TRUE, view_labels = FALSE)
## [1] "#A020F0" "#8019C0" "#601390" "#3F0C5F" "#200630"
With more colours, the hex codes get harder to view in the plot. They are printed in the console when the function is called on its own, and can also be assigned to an object for later use.
purple_palette