A family of ggplot2 color scales based on the solaris palette
(deep purple to gold). Available in continuous (_c), discrete
(_d), and binned variants for both fill and
colour aesthetics. American-spelling aliases (color)
are provided for all colour variants.
A diverging scale with purple at negative values, a white midpoint, and gold at positive values. Designed for centered data such as correlations, z-scores, anomaly scores, or deviations from a reference.
Usage
scale_fill_solaris_c(reverse = FALSE, ...)
scale_colour_solaris_c(reverse = FALSE, ...)
scale_fill_solaris_d(reverse = FALSE, ...)
scale_colour_solaris_d(reverse = FALSE, ...)
scale_fill_solaris_binned(n = 6, reverse = FALSE, ...)
scale_colour_solaris_binned(n = 6, reverse = FALSE, ...)
scale_fill_solaris_div(mid = "#ffffff", limit = NULL, ...)
scale_colour_solaris_div(mid = "#ffffff", limit = NULL, ...)Arguments
- reverse
Logical. If
TRUE, reverse the palette order (gold-to-purple instead of purple-to-gold). Default isFALSE.- ...
Additional arguments passed to
scale_fill_gradient2.- n
Integer. Number of bins (colors) to use for binned scales. Default is
6.- mid
Character. Color for the midpoint. Default is
"#ffffff"(white). Use"#fcfaf7"for a cream midpoint matching the solaris background, orNAfor no midpoint color (uses the continuous gradient).- limit
Numeric vector of length 2. Specifies the range that corresponds to the full gradient. Default is
NULL(automatic). For z-scores, uselimit = c(-3, 3). For correlations, uselimit = c(-1, 1).
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
# Continuous fill
ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
geom_tile() +
scale_fill_solaris_c()
# Discrete colour
ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
geom_point() +
scale_colour_solaris_d()
# Binned fill with 4 bins
ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
geom_tile() +
scale_fill_solaris_binned(n = 4)
} # }
if (FALSE) { # \dontrun{
library(ggplot2)
# Correlation matrix
df <- data.frame(
x = rep(c("A", "B", "C"), each = 3),
y = rep(c("X", "Y", "Z"), 3),
value = c(-0.8, 0.2, 0.5, 0.1, -0.9, 0.3, 0.4, -0.3, 0.7)
)
ggplot(df, aes(x, y, fill = value)) +
geom_tile() +
scale_fill_solaris_div(limit = c(-1, 1)) +
theme_solaris()
# Z-score distribution
set.seed(42)
scores <- data.frame(
score = rnorm(1000)
)
ggplot(scores, aes(x = score)) +
geom_histogram(binwidth = 0.2, fill = "zscore") +
scale_fill_solaris_div() +
theme_solaris()
} # }
