Skip to contents

Builds the palette vector rtemis.draw::draw_sankey() expects: one color per node, in the order that function derives its node list, so the two cannot fall out of step.

Usage

sankey_palette(
  x,
  links,
  candidate_fill = c("mix", "neutral"),
  palette = NULL,
  theme = c("light", "dark"),
  neutral = NULL,
  sentinel = NULL
)

Arguments

x

Mapping object, as returned by map_course_to_sessions().

data.frame: The output of as_sankey() for that mapping. Its nodes attribute supplies the node order and roles.

candidate_fill

Character {"mix", "neutral"}: How session objectives are colored.

palette

Character: Hex colors for course objectives, recycled if there are more objectives than colors. Defaults to a hue-spread subset of the rtemis palette; see the note above before substituting one.

theme

Character {"light", "dark"}: Which way the neutral grey should lean. Dark grey on a light ground, light grey on a dark one.

neutral

Character: Overrides the theme's grey for session objectives.

sentinel

Character: Color for the <uncovered> and <unaligned> nodes. Defaults to red, because an objective nothing covers is the finding a reader most needs to see.

Value

Character vector of hex colors, one per node, in node order.

Details

Course objectives (criteria) each take a distinct hue. Session objectives (candidates) are painted one of two ways:

  • "mix" blends the colors of the course objectives a session objective serves, weighted by strength. A blend is a convex combination in linear light, so it is never more saturated than the mean of its inputs and opposing hues cancel toward grey: a saturated node serves essentially one objective, a washed-out node is spread across several. Overlap is legible at a glance rather than by tracing ribbons.

    Read this relatively, not as an absolute saturation scale: the rtemis hues are not equal-chroma, so a node inheriting a muted course-objective color is muted without being shared. Compare a session objective against the course-objective colors feeding it. The default palette drops the pale and near-achromatic rtemis entries for this reason; a custom palette including them will make unshared session objectives look blended.

  • "neutral" paints them all one grey, when the ribbons alone should carry the story.

Mixing is done in linear light rather than on gamma-encoded sRGB values, so a blend is not darker than the colors going into it.

Author

EDG

Examples

if (FALSE) { # \dontrun{
  links <- as_sankey(mapping, threshold = 0.5)
  draw_sankey(links, palette = sankey_palette(mapping, links))
} # }