Diverging color scale for signed surprise values. Negative values (lower than expected) are shown in one color, positive values (higher than expected) in another, with neutral (zero) in the middle.
Usage
scale_fill_surprise_diverging(
low = scales::muted("blue"),
mid = "white",
high = scales::muted("red"),
midpoint = 0,
name = "Signed Surprise",
...
)
scale_colour_surprise_diverging(
low = scales::muted("blue"),
mid = "white",
high = scales::muted("red"),
midpoint = 0,
name = "Signed Surprise",
...
)
scale_color_surprise_diverging(
low = scales::muted("blue"),
mid = "white",
high = scales::muted("red"),
midpoint = 0,
name = "Signed Surprise",
...
)Arguments
- low
Color for negative surprise (lower than expected). Default is blue.
- mid
Color for zero surprise (as expected). Default is white.
- high
Color for positive surprise (higher than expected). Default is red.
- midpoint
Value of the midpoint. Default is 0.
- name
Legend title
- ...
Additional arguments passed to
ggplot2::scale_fill_gradient2()
Examples
library(ggplot2)
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
# Signed surprise with diverging scale - geometry must be mapped explicitly
ggplot(nc) +
geom_surprise(
aes(geometry = geometry, observed = SID74, expected = BIR74),
fill_type = "signed"
) +
scale_fill_surprise_diverging()