adobecolor is a package to read (and eventually write) Adobe color (ASE/ACO) files
In Envisioning Information, Edward Tufte says "…avoiding catastrophe becomes the first
principle in bringing color to information: Above all, do no harm." R users gain a quick upper hand
in adhering to this "do no harm" thanks to sane defaults in ggplot2
and packages like ggthemes and
RColorBrewer that enable use of established, good color palettes.
If you do visualization work in conjunction with a design shop or organization that establishes their own palettes and themes there will often be standard palettes that must be adhered to. These are usually stored and shared in some type of Adobe swatch file format. There are also many sites like Adobe Color CC and COLOUR Lovers where folks can create and share color palettes.
This package enables you to use the colors straight from .ase
or .aso
files and avoid the cutting/pasting of hex codes
or using color pickers to extract the color information. You can read these swatch files directly from the internet and/or
include the files directly in your R projects. This will make it easier to modify a resource versus change code.
NOTE that just beacuse an ASE or ACO file exists on the internet does not mean that it will let you "do no harm". You still need to use good judgement from knowledge/experience (or advice from experts) to ensure you are using colors effectively. This package just opens up the world of colors in R a little bit more.
The following functions are implemented:
read_aco
: Read colors from Adobe Color (ACO) filesread_ase
: Read colors from Adobe Swatch Exchange (ASE) filesshow_palette
:Display a color palette0.1
released0.2
released : ACO v2 supportdevtools::install_github("hrbrmstr/adobecolor")
options(width=80)
library(adobecolor) # current verison packageVersion("adobecolor")
One good source for palettes is the "Most Popular" section on Adobe Color CC. If you use the Adobe ecosystem, you can sync ASE palette files directly locally or download them directly (registration required).
The "Herbs and Spice" and "Keep the Change" palettes are kinda nifty, and also included in this package (since Adobe has yet to release the new API for the color site for automatic downloading). We can take a quick look at both of them. Here they are from the web site:
And, there they are via this package:
herbs_and_spice <- read_ase(system.file("palettes", "herbs_and_spice.ase", package="adobecolor")) print(herbs_and_spice) show_palette(herbs_and_spice)
keep_the_change <- read_ase(system.file("palettes", "keep_the_change.ase", package="adobecolor")) print(keep_the_change) show_palette(keep_the_change)
As said earlier, you can also read directly from a URL. Here is a "metal" palette ripped straight from github:
metal <- read_ase("https://github.com/picwellwisher12pk/en_us/raw/master/Swatches/Metal.ase") print(metal) show_palette(metal)
As you can see, this "metal" palette actually had named colors (albeit bland, CMYK value names).
Some palettes, like the Omega Nebula (CC-BY-SA davidgav) one included with the package, have license restrictions (the mind boggles), so be aware of that when blatantly using others' designs without attribution. David's palette has much better names:
omega_nebula <- read_ase(system.file("palettes", "omega_nebula.ase", package="adobecolor")) print(omega_nebula) show_palette(omega_nebula)
For some reason (I haven't poked at the source code yet or talked to @hadleywickham), ggplot scale_*_manual
(color/fill)'s do not
like named color vectors. So you need to use unname
(or use_names=FALSE
in read_ase
or read_aco
) before using them as values
:
library(ggplot2) gg <- ggplot(mtcars, aes(x=mpg, y=disp)) gg <- gg + geom_point(aes(col=factor(gear)), size=3) gg <- gg + scale_color_manual(values=unname(keep_the_change)) gg <- gg + theme_bw() gg
library(adobecolor) library(testthat) date() test_dir("tests/")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.