| Title: | Color Palettes Inspired by the Paintings of Candido Portinari |
|---|---|
| Description: | Color palettes inspired by paintings of Candido Portinari held by the Sao Paulo Museum of Art (MASP) and by his Guerra (War) and Paz (Peace) panels at the United Nations Headquarters. Provides qualitative, diverging and sequential palettes for discrete and continuous data, ready-made 'ggplot2' color and fill scales, and a colorblind-safety check that simulates protanopia, deuteranopia and tritanopia following Machado, Oliveira and Fernandes (2009) <doi:10.1109/TVCG.2009.113>. |
| Authors: | Rafa Lopes [aut, cre] |
| Maintainer: | Rafa Lopes <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0.9000 |
| Built: | 2026-10-29 11:57:52 UTC |
| Source: | https://github.com/rafalopespx/portinaricolors |
Discrete or continuous color and fill scales built from a Portinari palette.
They are ordinary ggplot2 scales and accept the usual arguments (name,
labels, breaks, guide, ...). Match the palette category to the data:
qualitative palettes for unordered groups, sequential palettes for ordered
values, and diverging palettes for values around a midpoint (see
portinari.palettes()).
scale_color_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... ) scale_colour_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... ) scale_fill_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... )scale_color_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... ) scale_colour_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... ) scale_fill_portinari( palette = "cafe", type = c("discrete", "continuous"), direction = 1, colorblind = FALSE, ... )
palette |
Name of the palette. See |
type |
|
direction |
|
colorblind |
If |
... |
Further arguments passed to |
A ggplot2 scale object.
library(ggplot2) # Qualitative: unordered groups ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size = 3) + scale_color_portinari("cafe", name = "Cylinders") # Sequential: ordered values ggplot(faithfuld, aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_portinari("guerra_azul", type = "continuous", direction = -1) # Diverging: values around a midpoint ggplot(mtcars, aes(wt, mpg, colour = mpg - mean(mpg))) + geom_point(size = 3) + scale_color_portinari("guerra", type = "continuous", name = "mpg vs mean") # Diverging, discrete: an ordered scale with a neutral middle ggplot(mtcars, aes(factor(gear), fill = factor(carb))) + geom_bar() + scale_fill_portinari("retirantes")library(ggplot2) # Qualitative: unordered groups ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size = 3) + scale_color_portinari("cafe", name = "Cylinders") # Sequential: ordered values ggplot(faithfuld, aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_portinari("guerra_azul", type = "continuous", direction = -1) # Diverging: values around a midpoint ggplot(mtcars, aes(wt, mpg, colour = mpg - mean(mpg))) + geom_point(size = 3) + scale_color_portinari("guerra", type = "continuous", name = "mpg vs mean") # Diverging, discrete: an ordered scale with a neutral middle ggplot(mtcars, aes(factor(gear), fill = factor(carb))) + geom_bar() + scale_fill_portinari("retirantes")
Simulates protanopia, deuteranopia and tritanopia (Machado et al., 2009) and
measures the smallest CIELAB color difference (CIE76 dE) within the discrete
palette of n colors returned by portinari.pal(), for every n. A
discrete palette of n colors is colorblind-safe when all three
simulations keep that minimum at or above threshold.
portinari.cvd.check(palette = "cafe", threshold = 10)portinari.cvd.check(palette = "cafe", threshold = 10)
palette |
Name of the palette. See |
threshold |
Minimum acceptable dE. Default |
A data frame with one row per palette size n (from 2 up to the
palette length) and columns normal, protanopia, deuteranopia and
tritanopia (minimum pairwise dE in each condition) and
colorblind_safe.
portinari.cvd.check("inah")portinari.cvd.check("inah")
Returns a vector of hex colors from a Portinari palette.
portinari.pal( palette = "cafe", n, type = c("discrete", "continuous"), direction = 1, colorblind = FALSE )portinari.pal( palette = "cafe", n, type = c("discrete", "continuous"), direction = 1, colorblind = FALSE )
palette |
Name of the palette. See |
n |
Number of colors. Defaults to the length of the palette (or of its
colorblind-safe subset when |
type |
|
direction |
|
colorblind |
If |
Palettes come in three categories (see portinari.palettes()):
qualitative palettes for unordered groups, sequential palettes for
ordered values, and diverging palettes for values around a meaningful
midpoint. Discrete palettes pick n colors that suit the category: the most
distinct colors for qualitative palettes, evenly spaced steps for sequential
palettes, and balanced steps either side of the light center for diverging
palettes. Continuous palettes interpolate the full palette in CIELAB space.
A character vector of hex colors with class "portinari_palette".
scale_color_portinari(), scale_fill_portinari(),
portinari.palettes()
portinari.pal("cafe") portinari.pal("retirantes", n = 3) portinari.pal("guerra_azul", n = 20, type = "continuous") portinari.pal("inah", colorblind = TRUE)portinari.pal("cafe") portinari.pal("retirantes", n = 3) portinari.pal("guerra_azul", n = 20, type = "continuous") portinari.pal("inah", colorblind = TRUE)
List the available Portinari palettes
portinari.palettes(category = NULL)portinari.palettes(category = NULL)
category |
Optional filter: one or more of |
A data frame with one row per palette: its category, the number of
colors, how many colors are colorblind-safe (cvd_n), whether the whole
palette is colorblind-friendly, and a short description. See
portinari.works() for the paintings behind each palette.
portinari.palettes() portinari.palettes("diverging")portinari.palettes() portinari.palettes("diverging")
The works each palette was drawn from, with links to the collection pages.
The sequential palettes guerra_azul and paz_ouro are derived from
guerra and paz and share their works.
portinari.works(palette = NULL)portinari.works(palette = NULL)
palette |
Optional character vector of palette names to filter by. |
A data frame with columns palette, title, year, collection,
inventory, url (collection or story page) and image_url (the
museum's image, where one is published; NA otherwise).
portinari.works() portinari.works("retirantes")portinari.works() portinari.works("retirantes")
Draws each palette as a row of color swatches using base graphics, labeled with its category.
show_portinari(palette = NULL, category = NULL)show_portinari(palette = NULL, category = NULL)
palette |
Character vector of palette names. Defaults to all palettes
(or all palettes in |
category |
Optional filter: one or more of |
The palette names, invisibly.
show_portinari() show_portinari(category = "diverging") show_portinari(c("cafe", "inah"))show_portinari() show_portinari(category = "diverging") show_portinari(c("cafe", "inah"))
A complete ggplot2 theme that dresses a plot like one of Portinari's
canvases: a warm ground of raw linen, firm drawn contours instead of a boxed
panel, earth-colored lettering and an optional painted frame. Two further
moods follow his United Nations panels: the deep indigo of Guerra and the
golden light of Paz. Pair it with scale_color_portinari() and
scale_fill_portinari().
theme_portinari( mood = c("canvas", "guerra", "paz"), base_size = 11, base_family = "", grid = c("y", "x", "xy", "none"), frame = TRUE )theme_portinari( mood = c("canvas", "guerra", "paz"), base_size = 11, base_family = "", grid = c("y", "x", "xy", "none"), frame = TRUE )
mood |
The overall look. |
base_size |
Base font size, in points. |
base_family |
Base font family. |
grid |
Which major grid lines to draw: |
frame |
If |
A ggplot2 theme object.
The light moods share their ground with the lightest colors of several
palettes (the creams of cafe and paz, the light centers of the diverging
palettes, the pale ends of the sequential ones). That is natural for filled
areas such as heatmaps, where the center then reads as neutral, but those
colors fade when used for points or lines. The guerra mood uses the indigo
that starts guerra and guerra_azul, so pair it with other palettes, for
example paz or sofia: the ground of War with the colors of Peace.
scale_color_portinari(), scale_fill_portinari()
library(ggplot2) ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size = 3) + scale_color_portinari("paz", name = "Cylinders") + labs(title = "Fuel economy", subtitle = "Heavier cars travel less per gallon") + theme_portinari() ggplot(mpg, aes(class, fill = drv)) + geom_bar() + scale_fill_portinari("sofia") + theme_portinari("guerra") ggplot(faithfuld, aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_portinari("roxa_terra", type = "continuous", direction = -1) + theme_portinari("paz", grid = "none", frame = FALSE)library(ggplot2) ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size = 3) + scale_color_portinari("paz", name = "Cylinders") + labs(title = "Fuel economy", subtitle = "Heavier cars travel less per gallon") + theme_portinari() ggplot(mpg, aes(class, fill = drv)) + geom_bar() + scale_fill_portinari("sofia") + theme_portinari("guerra") ggplot(faithfuld, aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_portinari("roxa_terra", type = "continuous", direction = -1) + theme_portinari("paz", grid = "none", frame = FALSE)