The house color rule for EDA and follow-up figures, as a named vector you
can check or reuse: an event is vermillion, censored is blue, missing is
light gray, and every other level takes a colorblind-safe color in order.
To apply the rule to a plot, use scale_fill_hv() or scale_color_hv(),
which call this for each panel.
Arguments
- levels
Character vector of distinct level names, in drawing order.
- event, censored
Level names that take the event or the censored color, or
NULLfor none. Names not inlevelsare ignored.- missing
Level name that stands for missing values.
"(Missing)"is the explicit levelhv_eda()adds.
Details
Every color is decided from levels alone:
A level named in
eventis#D55E00, incensored#0072B2, and inmissing#CCCCCC. These hold even when the level is the only one.Every other level, in
levelsorder, takes the light series ofhv_ppt_palette(): the Okabe-Ito colors without yellow and sky blue, starting at blue, so a sole level with no role is blue.When any of
levelsis named ineventorcensored, blue and vermillion leave that series, so no other level can be mistaken for the event or for censored. A role name absent fromlevelschanges nothing, so one call can serve panels that do and do not carry the event.When the other levels outnumber the series, all of them switch to Paul Tol's muted palette, without its sand and cyan, and without its rose when a role is present. Beyond that there are no more colorblind-safe colors, and the function stops with an error of class
hv_role_palette_capacity.
Every color except the missing gray is at least 2:1 against white. The gray is fainter on purpose: missing is the one level meant to recede.
See also
scale_fill_hv() and scale_color_hv() to apply the rule to a
plot; hv_ppt_palette() for series colors with no role attached.