Returns a named character vector of hex color codes from an Insper palette. When printed interactively, displays a visual color swatch. The result behaves as a plain character vector and can be used directly anywhere colors are accepted.
Arguments
- palette
Character. Palette name. Use
show_insper_palettesto see all options.- n
Integer or NULL. Number of colors to return. If NULL (default), returns all colors in the palette. If
nexceeds the palette size, colors are interpolated smoothly usingcolorRampPalette.- reverse
Logical. If TRUE, reverses the color order. Default FALSE.
Value
An object of class insper_palette (a named character vector of
hex codes). Printing displays a visual swatch. Use as.character() to
strip the class if needed.
Details
Available palettes by type:
Qualitative: main, muted, colorblind, cidades
Sequential: vermelho, turquesa, verde, amarelo, laranja, rosa, roxo, cinza, azul, cidades_folhagem, cidades_solar, cidades_asfalto, cidades_tijolo
Diverging: vermelho_turquesa (default for diverging data), roxo_verde, laranja_roxo, rosa_verde, cidades_folhagem_asfalto, cidades_folhagem_tijolo
Insper Cidades
Palettes prefixed cidades belong to the Insper Cidades sub-brand
(Centro de Estudos das Cidades / Laboratório Arq.Futuro) and are built from
its own application manual rather than the institutional brand kit. They are
opt-in: nothing in the package defaults to them.
Do not mix them with the institutional palettes in one chart. The two
families sit close together in CIELAB — asfalto is only 6.6 dE from
roxo, and solar 8.8 dE from laranja — close enough that a
chart drawing from both reads as a rendering error rather than a design
choice. Pick one family per chart.
The Cidades manual ships no tints or shades, so the four cidades_*
sequential ramps are derived: seven steps each, with the official color pinned
at position 4. For diverging data prefer cidades_folhagem_asfalto,
which has the widest colorblind separation of any diverging palette in the
package; cidades_folhagem_tijolo is more symmetric in lightness (so it
reads better in greyscale) but pairs green against orange-red, which is hard
under red-green color vision deficiency.
All palettes are built from the 2026 Insper brand kit except
"colorblind", which is the Okabe-Ito set
(https://jfly.uni-koeln.de/color/) and contains no Insper tokens. It is
bundled as an accessibility fallback for when the brand hues in "main"
cannot be told apart by colorblind readers — "main" mixes red, green,
orange and yellow, which is a difficult combination under the common forms of
color vision deficiency. Use "main" for on-brand work and reach for
"colorblind" when distinguishability matters more than brand fidelity.
Examples
# Get all colors from a palette
insper_palette("main")
# Subset to n colors
insper_palette("vermelho", n = 3)
# Reverse order
insper_palette("vermelho_turquesa", reverse = TRUE)
# Use directly in a plot
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
geom_point(color = insper_palette("vermelho", n = 1))
# Use in manual scales
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
scale_color_manual(values = insper_palette("main", n = 3))
