Skip to contents

Given a set of palettes and a column of data to use to determine color (and possibly a grouping column), this assigns color to each node. Can also be short-circuited by passing a scalar color or column of color names. Edge tibbles get a color column, while nodes get fillcolor, matching DiagrammeR attribute names. The fontcolor attribute is also set for nodes as black or white depending on the fillcolor

Usage

causal_colors_general(
  df,
  pal_list,
  pal_direction = rep(1, length(pal_list)),
  colorgroups = NULL,
  colorset = NULL,
  setLimits = NULL
)

Arguments

df

a tibble or dataframe, nodes or edges

pal_list

a named list of paletteer palettes or a scalar character specifying color.

  • named list: names should match the values in the colorgroups column, which determine which palettes apply to which rows. If colorgroups = NULL, the name doesn't matter, but often clearest to match colorset

  • character (scalar or vector): short-circuits the palette finding and creates a color column with the given colors.

pal_direction

vector of length pal_list, either 1 (default) or -1 (reversed) direction of the palettes

colorgroups

NULL (the default) or length-1 character vector specifying a grouping column, with different palettes applied to the different groups. If NULL, one palette is applied across all of the rows

colorset

a length-1 character vector specifying the column to use to define color. Type doesn't matter, but behaviour differs. If numeric it will space the colors for each row according to value, if not numeric, colors for each row are spaced evenly along the palette.

setLimits

NULL (default) or length-2 numeric vector to force limits of the color scale.

Value

an edge tibble with a color column or a node tibble with fillcolor and fontcolor