scaleDiscrete

fun scaleDiscrete(aesthetic: Any, direction: Int? = null, name: String? = null, breaks: Any? = null, labels: Any? = null, lablim: Int? = null, limits: List<Any>? = null, naValue: Any? = null, format: String? = null, guide: Any? = null, scaleMapperKind: String? = null, otherOptions: Map<String, Any?>? = null): Scale

General purpose scale for discrete data. Use it to adjust most common properties of a default scale for given aesthetic.

Parameters

aesthetic

Aesthetic or a list of aesthetics that this scale works with.

direction

default = 1. Only for color scales: sets the order of colors in the scale. 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

List of data values. A vector specifying values to display with the scale and their order in guides (axis).

naValue

Missing values will be replaced with this value.

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.

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".

scaleMapperKind

The type of the scale: ("identity", "color_gradient", "color_gradient2", "color_gradientn", "color_hue", "color_grey", "color_brewer", "color_cmap", "size_area"). If null (the default) and the scale is color, then "color_brewer" will be used.

otherOptions

Additional parameters for the specified scale type.