phiz

Scales and guides API

Scale methods set the domain, range, transformation, labels, and guide of one aesthetic. Scales, coordinates, and labels shows them with examples.

Methods: scale() · scaleX() · scaleY() · scaleColor() · scaleFill() · scaleSize() · scaleShape() · scaleOpacity() · scaleLinetype() · guides() · xlim() · ylim()

Functions: scale_x() · scale_y() · scale_x_continuous() · scale_y_continuous() · scale_x_log10() · scale_y_log10() · scale_x_sqrt() · scale_y_sqrt() · scale_x_reverse() · scale_y_reverse() · scale_x_date() · scale_y_date() · scale_color() · scale_fill() · scale_size() · scale_shape() · scale_alpha() · scale_linetype() · scale_color_manual() · scale_fill_manual() · scale_color_scheme() · scale_fill_scheme() · scale_color_viridis() · scale_fill_viridis() · scale_color_brewer() · scale_fill_brewer() · scale_color_gradient() · scale_fill_gradient() · scale_color_gradient2() · scale_fill_gradient2() · viridis_scheme() · brewer_scheme() · scale_color_viridis_d() · scale_fill_viridis_d() · scale_color_viridis_c() · scale_fill_viridis_c() · scale_color_viridis_b() · scale_fill_viridis_b() · scale_color_distiller() · scale_fill_distiller() · scale_color_fermenter() · scale_fill_fermenter() · scale_color_gradientn() · scale_fill_gradientn() · scale_color_grey() · scale_fill_grey() · scale_color_hue() · scale_fill_hue() · scale_color_identity() · scale_fill_identity() · scale_x_discrete() · scale_y_discrete() · guides() · guide_legend() · guide_colorbar() · guide_colourbar() · guide_axis() · guide_none() · label_number() · label_comma() · label_percent() · label_dollar() · label_scientific() · label_date() · xlim() · ylim()

scale()

->scale(string $aesthetic, mixed ...$options): Plot

Sets the scale for an aesthetic; see Scale::make() for the options.

scaleX()

->scaleX(mixed ...$options): Plot

x scale: type (linear, log, sqrt, time, …), domain, range, zero, nice, reverse, name, breaks, labels, format.

Functions: scale_x(), scale_x_continuous(), scale_x_log10(), scale_x_sqrt(), scale_x_reverse(), scale_x_date(), scale_x_discrete().

scaleY()

->scaleY(mixed ...$options): Plot

Scale and guide options for y, as scaleX() takes them.

Functions: scale_y(), scale_y_continuous(), scale_y_log10(), scale_y_sqrt(), scale_y_reverse(), scale_y_date(), scale_y_discrete().

scaleColor()

->scaleColor(mixed ...$options): Plot

Color scale: scheme (‘viridis’, ‘blues’, ‘category10’, …), range, values (manual palette), domainMid, …

Functions: scale_color(), scale_color_manual(), scale_color_scheme(), scale_color_viridis(), scale_color_brewer(), scale_color_gradient(), scale_color_gradient2(), scale_color_viridis_d(), scale_color_viridis_c(), scale_color_viridis_b(), scale_color_distiller(), scale_color_fermenter(), scale_color_gradientn(), scale_color_grey(), scale_color_hue(), scale_color_identity().

scaleFill()

->scaleFill(mixed ...$options): Plot

Scale and guide options for fill, as scaleColor() takes them.

Functions: scale_fill(), scale_fill_manual(), scale_fill_scheme(), scale_fill_viridis(), scale_fill_brewer(), scale_fill_gradient(), scale_fill_gradient2(), scale_fill_viridis_d(), scale_fill_viridis_c(), scale_fill_viridis_b(), scale_fill_distiller(), scale_fill_fermenter(), scale_fill_gradientn(), scale_fill_grey(), scale_fill_hue(), scale_fill_identity().

scaleSize()

->scaleSize(mixed ...$options): Plot

Scale and guide options for size: range sets the smallest and largest areas in square pixels.

Function: scale_size().

scaleShape()

->scaleShape(mixed ...$options): Plot

Scale and guide options for shape: values sets the shapes, by level or in level order.

Function: scale_shape().

scaleOpacity()

->scaleOpacity(mixed ...$options): Plot

Scale and guide options for opacity (alpha): range sets the lowest and highest opacity.

Function: scale_alpha().

scaleLinetype()

->scaleLinetype(mixed ...$options): Plot

Scale and guide options for linetype: values sets the dash patterns, by level or in level order.

Function: scale_linetype().

guides()

->guides(mixed ...$guides): Plot

Guides per aesthetic, as ggplot2’s guides(): ‘none’ or false hides one, and an array sets axis or legend properties (see guide_legend(), guide_colorbar(), and guide_axis()).

Function: guides().

xlim()

->xlim(string|int|float $min, string|int|float $max): Plot

Fixes the x domain. Unlike ggplot2’s xlim(), data outside it is clipped rather than dropped.

Function: xlim().

ylim()

->ylim(string|int|float $min, string|int|float $max): Plot

Fixes the y domain. Unlike ggplot2’s ylim(), data outside it is clipped rather than dropped.

Function: ylim().

Functions

scale_color_manual()

scale_color_manual(array $values, mixed ...$args): Closure

Manual colors: a level => color map, or colors in level order.

scale_fill_manual()

scale_fill_manual(array $values, mixed ...$args): Closure

The scale_color_manual() scale for the fill aesthetic.

scale_color_scheme()

scale_color_scheme(string $scheme, mixed ...$args): Closure

Vega color schemes by name, such as ‘viridis’, ‘blues’, ‘set2’, ‘dark2’, ‘tableau10’.

scale_fill_scheme()

scale_fill_scheme(string $scheme, mixed ...$args): Closure

The scale_color_scheme() scale for the fill aesthetic.

scale_color_viridis()

scale_color_viridis(string $option = 'viridis', mixed ...$args): Closure

A viridisLite palette by Vega scheme name, such as ‘viridis’, ‘magma’, or ‘cividis’.

scale_fill_viridis()

scale_fill_viridis(string $option = 'viridis', mixed ...$args): Closure

The scale_color_viridis() scale for the fill aesthetic.

scale_color_brewer()

scale_color_brewer(string $palette = 'set1', mixed ...$args): Closure

A ColorBrewer palette for discrete data, as ggplot2’s scale_colour_brewer (names are case-insensitive).

scale_fill_brewer()

scale_fill_brewer(string $palette = 'set1', mixed ...$args): Closure

The scale_color_brewer() scale for the fill aesthetic.

scale_color_gradient()

scale_color_gradient(    string $low = '#132B43',    string $high = '#56B1F7',    mixed ...$args,): Closure

A two-color gradient, as ggplot2’s scale_colour_gradient (defaults #132B43 to #56B1F7).

scale_fill_gradient()

scale_fill_gradient(    string $low = '#132B43',    string $high = '#56B1F7',    mixed ...$args,): Closure

The scale_color_gradient() scale for the fill aesthetic.

scale_color_gradient2()

scale_color_gradient2(    string $low = '#832424',    string $mid = '#FFFFFF',    string $high = '#3A3A98',    int|float $midpoint = 0,    mixed ...$args,): Closure

A diverging gradient through mid at midpoint, as ggplot2’s scale_colour_gradient2.

scale_fill_gradient2()

scale_fill_gradient2(    string $low = '#832424',    string $mid = '#FFFFFF',    string $high = '#3A3A98',    int|float $midpoint = 0,    mixed ...$args,): Closure

The scale_color_gradient2() scale for the fill aesthetic.

viridis_scheme()

viridis_scheme(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,): array

viridisLite palettes by option: A magma, B inferno, C plasma, D viridis, E cividis, H turbo (or the names).

brewer_scheme()

brewer_scheme(string $palette, int $direction = 1): array|string

A ColorBrewer scheme, reversed when direction is -1.

scale_color_viridis_d()

scale_color_viridis_d(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

viridis for discrete (_d), continuous (_c), and binned (b) scales, as ggplot2’s scale_colour_viridis*.

scale_fill_viridis_d()

scale_fill_viridis_d(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

The scale_color_viridis_d() scale for the fill aesthetic.

scale_color_viridis_c()

scale_color_viridis_c(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

The pipe form of ->scaleColor().

scale_fill_viridis_c()

scale_fill_viridis_c(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

The scale_color_viridis_c() scale for the fill aesthetic.

scale_color_viridis_b()

scale_color_viridis_b(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

The pipe form of ->scaleColor().

scale_fill_viridis_b()

scale_fill_viridis_b(    string $option = 'D',    float $begin = 0.0,    float $end = 1.0,    int $direction = 1,    mixed ...$args,): Closure

The scale_color_viridis_b() scale for the fill aesthetic.

scale_color_distiller()

scale_color_distiller(    string $palette = 'Blues',    int $direction = -1,    mixed ...$args,): Closure

ColorBrewer for continuous data, as ggplot2’s scale_colour_distiller (reversed by default, as there).

scale_fill_distiller()

scale_fill_distiller(    string $palette = 'Blues',    int $direction = -1,    mixed ...$args,): Closure

The scale_color_distiller() scale for the fill aesthetic.

scale_color_fermenter()

scale_color_fermenter(    string $palette = 'Blues',    int $direction = -1,    mixed ...$args,): Closure

ColorBrewer for binned continuous data, as ggplot2’s scale_colour_fermenter.

scale_fill_fermenter()

scale_fill_fermenter(    string $palette = 'Blues',    int $direction = -1,    mixed ...$args,): Closure

The scale_color_fermenter() scale for the fill aesthetic.

scale_color_gradientn()

scale_color_gradientn(array $colors, mixed ...$args): Closure

A gradient through several colors, as ggplot2’s scale_colour_gradientn.

scale_fill_gradientn()

scale_fill_gradientn(array $colors, mixed ...$args): Closure

The scale_color_gradientn() scale for the fill aesthetic.

scale_color_grey()

scale_color_grey(float $start = 0.2, float $end = 0.8, mixed ...$args): Closure

Grays for discrete data, as ggplot2’s scale_colour_grey (computed for the number of levels).

scale_fill_grey()

scale_fill_grey(float $start = 0.2, float $end = 0.8, mixed ...$args): Closure

The scale_color_grey() scale for the fill aesthetic.

scale_color_hue()

scale_color_hue(    array $h = [0 => 15,1 => 375],    int|float $c = 100,    int|float $l = 65,    int|float $hStart = 0,    int $direction = 1,    mixed ...$args,): Closure

ggplot2’s hue palette with its options, as scale_colour_hue (computed for the number of levels).

scale_fill_hue()

scale_fill_hue(    array $h = [0 => 15,1 => 375],    int|float $c = 100,    int|float $l = 65,    int|float $hStart = 0,    int $direction = 1,    mixed ...$args,): Closure

The scale_color_hue() scale for the fill aesthetic.

scale_color_identity()

scale_color_identity(mixed ...$args): Closure

The data values are the colors (or sizes, or shapes) themselves, with no legend, as ggplot2’s scale_*_identity.

scale_x_discrete()

scale_x_discrete(?array $limits = null, mixed ...$args): Closure

Discrete position scales: limits orders (and subsets) the levels, labels renames them.

scale_y_discrete()

scale_y_discrete(?array $limits = null, mixed ...$args): Closure

The scale_x_discrete() scale for the y axis.

guides()

guides(mixed ...$guides): Closure

Axis or legend options per aesthetic, as ggplot2’s guides(): guides(color: ‘none’, x: guide_axis(angle: 45)).

guide_legend()

guide_legend(    ?string $title = null,    ?int $ncol = null,    ?string $direction = null,    mixed ...$properties,): array

Legend options: title, columns (ncol), direction (horizontal or vertical), and further Vega-Lite legend properties.

guide_colorbar()

guide_colorbar(    ?string $title = null,    int|float|null $barwidth = null,    int|float|null $barheight = null,    ?string $direction = null,    mixed ...$properties,): array

Color bar options: barwidth and barheight in pixels.

guide_colourbar()

guide_colourbar(mixed ...$args): array

An alias of guide_colorbar().

guide_axis()

guide_axis(    ?string $title = null,    int|float|null $angle = null,    ?string $position = null,    mixed ...$properties,): array

Axis options: angle turns the labels anticlockwise, as ggplot2’s guide_axis(angle =); position is top, bottom, left, or right.

guide_none()

guide_none(): bool

Hides a guide, as ggplot2’s guide_none(): guides(color: guide_none()).

label_number()

label_number(    int|float|null $accuracy = null,    int|float $scale = 1,    string $prefix = '',    string $suffix = '',    string $bigMark = ',',): Label

Number labels, as scales::label_number(): accuracy rounds, scale multiplies, prefix and suffix wrap.

label_comma()

label_comma(    int|float|null $accuracy = null,    int|float $scale = 1,    string $prefix = '',    string $suffix = '',): Label

Thousands separators, as scales::label_comma().

label_percent()

label_percent(    int|float|null $accuracy = null,    int|float $scale = 100,    string $prefix = '',    string $suffix = '%',): Label

Percentages of proportions, as scales::label_percent(): 0.25 becomes 25%.

label_dollar()

label_dollar(    int|float|null $accuracy = null,    int|float $scale = 1,    string $prefix = '$',    string $suffix = '',): Label

Currency, as scales::label_dollar().

label_scientific()

label_scientific(int $digits = 3): Label

Scientific notation with digits significant digits, as scales::label_scientific().

label_date()

label_date(string $format = '%Y-%m-%d'): Label

Dates and times with a strftime-style format, as scales::label_date().

xlim()

xlim(string|int|float $min, string|int|float $max): Closure

The pipe form of ->xlim().

ylim()

ylim(string|int|float $min, string|int|float $max): Closure

The pipe form of ->ylim().