scaleColorBrewer

fun scaleColorBrewer(type: String? = null, palette: Any? = null, direction: Number? = null, name: String? = null, breaks: Any? = null, labels: Any? = null, lablim: Int? = null, limits: Any? = null, naValue: Any? = null, format: String? = null, guide: Any? = null, trans: String? = null): Scale

Sequential, diverging and qualitative color scales from colorbrewer.org for color aesthetic.

Palettes:

  • Diverging : BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral.

  • Qualitative : Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3.

  • Sequential : Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu, YlOrBr, YlOrRd.

Parameters

type

One of seq (sequential), div (diverging) or qual (qualitative) types of scales.

palette

String or Number. If a string, will use that named palette. If a number, will index into the list of palettes of appropriate type.

direction

Sets the order of colors in the scale. If 1, the default, colors are as output by brewer.pal. If -1, the order of colors is reversed.

name

The name of the scale - used as the axis label or the legend title. If null, the default, the name of the scale is taken from the first mapping used for that aesthetic.

breaks

A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.

labels

A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.

lablim

The maximum label length (in characters) before trimming is applied.

limits

Data range for this scale. Continuous scale: a pair of numbers providing limits of the scale. Use null to refer to default min/max. Discrete scale: list of data values to display, and their order.

naValue

An aesthetic value which is used when data in not available.

format

Specifies the format pattern for labels on the scale.

guide

Guide to use for this scale. It can either be a string ("colorbar", "legend") or a call to a guide function (guideColorbar(), guideLegend()) specifying additional arguments. "none" will hide the guide.

trans

Name of built-in transformation ("identity", "log10", "log2", "symlog", "reverse", "sqrt").

Format patterns in the format parameter can be just a number format (like "d") or a string template where number format is surrounded by curly braces: "{d} cylinders". Note: the "$" must be escaped as "\$". For more info see: formats.html

Examples:

  • ".2f" -> "12.45"

  • "Score: {.2f}" -> "Score: 12.45"

  • "Score: {}" -> "Score: 12.454789"