Skip to contents

Colours each mark by the value of a column. A numeric column becomes a continuous gradient and a character or factor column gets one colour per distinct value.

Usage

set_color(chart, color, palette = NULL, alpha = NULL)

Arguments

chart

Defines which chart to modify.

color

Defines which column the colours are drawn from. Omitted for heat charts.

palette

default NULL. Defines which colours to use, either the name of an Esri ramp such as "Blue 3" or a vector of R colours. NULL uses the ramp the ArcGIS SDK itself defaults to.

alpha

default NULL. Sets how opaque the marks are, from 0 for invisible to 1 for solid. Overrides whatever opacity the palette carries, on the marks and their outlines alike. NULL leaves them solid.

Value

chart, with its colour set.

Details

On a bar or line chart, colouring by a column other than x also groups the chart: it gains one series per distinct value, dodged side by side. Use set_position() to stack them instead. Numeric columns are always a gradient and never a group, the same rule as ggplot2.

Heat charts shade cells by how many rows fall into each, so there is no column to map. Give them palette on its own.

Examples

df <- data.frame(species = c("a", "b", "c"), mass = c(1, 5, 3))

arc_col(df, species, mass) |>
  set_color(mass, palette = "Red 1")