lepidochroma
is an R package including palettes that
were created inspired by the colours of butterfly species. They are
intended to provide elegant chromatic choices for any graphs or maps
generated in your analyses, while also keeping accessibility in mind, as
most of the palettes are colour blind friendly.
This vignette will briefly explain how to preview, access, and use the colour palettes available in the package.
To access a palette, simply call the lepidochroma()
function with the name of the palette you want to use. Palettes in this
package are named after the genus of the butterfly they are inspired by.
For example:
To get a list of all the available palettes, use the
lepidochroma_palettes()
function, which returns a data
frame with information about each palette.
lepidochroma_palettes()
#> name n_colours type colourblind_friendly
#> 1 attacus 6 discrete TRUE
#> 2 battus Inf continuous TRUE
#> 3 charaxes 6 discrete FALSE
#> 4 danaus Inf continuous TRUE
#> 5 diaethria 6 discrete TRUE
#> 6 eryphanis 5 discrete TRUE
#> 7 inachis 6 discrete TRUE
#> 8 morpho Inf continuous TRUE
#> 9 ornithoptera 6 discrete FALSE
#> 10 parthenos 6 discrete FALSE
#> 11 polyommatus 5 discrete TRUE
#> 12 teinopalpus Inf continuous FALSE
The lepidochroma_display()
function shows previews of
the palettes. If called without arguments, it will display all available
palettes in the package.
It is possible to show only continuous, discrete, or colourblind-friendly palettes by specifying the appropriate arguments to this function (refer to its documentation for more details). For example, here are the continuous color palettes that are colorblind-friendly:
Finally, a palette can be displayed by passing its name to
lepidochroma_display()
. The number of colours displayed can
also be controlled. For continuous palettes, you can preview an
interpolation of their colours like this:
Using discrete colour palettes is simple. Below, we use the Inachis palette to color the iris dataset. The plot shows the relationship between Petal.Length and Petal.Width, with different colors for different species.
inachis <- lepidochroma("inachis")
plot_colours <- inachis[c(3, 4, 5)]
plot(
Petal.Length ~ Petal.Width, data = iris,
col = plot_colours[iris$Species], pch = 20,
main = "Inachis"
)
With lepidochroma
, you can easily enhance your
visualizations using colors inspired by butterfly species. Whether
you’re using discrete or continuous palettes, the package ensures that
your plots are not only visually appealing but also accessible to all
users, including those with color blindness.
For more details, check the documentation of each function using
?lepidochroma
, ?lepidochroma_palettes
, and
?lepidochroma_display
.