sanzo
An R package by JRMA Maasch (2019).
Inspired by the art and color research of Sanzo Wada, his Dictionary Of Color Combinations, and the incredible interactive site by Dain M. Blodorn Kim, this package brings Wada’s color combinations to R for easy use in data visualizations. This package honors 60 of Wada’s color combinations: 20 duos, 20 trios, and 20 quads.
Sanzo Wada (1883-1967) was an artist, teacher, costume and kimono designer during a turbulent time in avant-garde Japanese art and cinema. Wada was ahead of his time in developing traditional and Western influenced color combinations, helping to lay the foundations for contemporary color research. Based on his original 6-volume work from the 1930s, this book offers 348 color combinations with CMYK and Pantone numbers, as attractive and sensuous as the book’s own design. – A Dictionary Of Color Combinations
This package is licensed under the GNU General Public License v3.0 (GPL-3).
# Install package. Prior, the package devtools must be installed but need not be loaded.
::install_github("jmaasch/sanzo")
devtools
# Load package.
library(sanzo)
View this vignette for additional package documentation, or precede any function by a question mark to access description, arguments, return value, and usage suggestions.
# Access function documentation.
sanzo.info2()
?sanzo.trio() ?
sanzo.demo
functions.Each color combination can be demo’d via base R scatter and bar plots. To view the output of these functions, see Full suite: Duo palettes. | Trio palettes. | Quad palettes.
# Print demo plots for duos.
sanzo.demo2()
# Print demo plots for trios.
sanzo.demo3()
# Print demo plots for quads.
sanzo.demo4()
# Print demo plots for all palettes.
sanzo.demo.all()
Optional: for easier viewing, try gridding up prior to
running sanzo.demo
functions. NOTE: This
will alter par
settings.
# Set up gridded layout, if desired:
::layout(matrix(1:4, nrow = 2))
graphics::par(mar = c(2, 2, 2, 2)) graphics
All examples use data from the datasets
package and
should be replicable.
# Assign palette to a name if desired.
<- sanzo.duo("c229")
my_duo <- sanzo.trio("c223")
my_trio <- sanzo.quad("c252")
my_quad
# Use palette that has been assigned to a name.
plot(iris$Sepal.Length, iris$Sepal.Width, col = my_quad)
# Use directly.
plot(iris$Sepal.Length, iris$Sepal.Width, col = sanzo.duo("c085"))
ggplot2
.Use with scale_fill_manual
or
scale_color_manual
. All examples use data from the
datasets
package and should be replicable.
ggplot(iris, aes(fill = Species, y = Sepal.Width, x = Sepal.Length)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = sanzo.trio("c223"))
By default, sanzo
palettes are discrete. There are
multiple ways to achieve a gradient. For example, using
scale_fill_gradientn
or scale_color_gradientn
in ggplot2
allows you to use any sanzo
palette
as a continuous gradient. See example visualizations here.
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density), interpolate = TRUE) +
scale_fill_gradientn(colors = sanzo.duo("c102"))
sanzo.info
functions.These functions return a data frame containing long-form names, short-form IDs, hexadecimal values, and links to Dain M. Blodorn Kim’s https://sanzo-wada.dmbk.io for further information.
<- sanzo.info2()
duo_info_df
<- sanzo.info3()
trio_info_df
<- sanzo.info4()
quad_info_df
<- sanzo.info.all()
info_df
# Two ways to print a data frame.
print(sanzo.info2())
::kable(sanzo.info2()) knitr
Duo, trio, and quad data are stored in exported lists. To quickly access palette names only:
names(duos)
names(trios)
names(quads)
Concatenate multiple palettes to make a custom palette or cherry-pick
individual colors. All hexadecimals are provided by the
sanzo.demo
functions and sanzo.info
functions.
<- sanzo.duo("c033")
c033 <- sanzo.duo("c095")
c095 <- c(c033, c095) custom_quad
For a more muted color palette, select an alpha less than 1. In the
plot at right, alpha = 5/6
.
ggplot2
galleryMany of the plots in this gallery additionally use the
ggthemes
and cowplot
packages.
Combination 205,
alpha = 3/4. |
Combination 194,
alpha = 3/4. |
Combination 121,
alpha = 3/4. |
Combination 172,
alpha = 3/4. |
See how to use sanzo
color combinations as continuous
palettes here.