phiz

Reference

API reference

This reference is generated from the public signatures and docblocks in src/. Every method that adds or changes something returns a new Plot, and the plot it was called on is unchanged.

Exceptions

  • InvalidArgumentException for input phiz cannot use, such as an unknown aesthetic, scale type, theme, or legend position, a geom without an aesthetic it needs, data that is neither rows nor columns, or a plot with no layers. The message names the problem.
  • Phiz\Exceptions\VlConvertNotFound when static export cannot find the vl-convert binary.
  • Phiz\Exceptions\ExportFailed when vl-convert fails, times out, or writes nothing, or when a file cannot be written.

Both export exceptions implement Phiz\Exceptions\PhizException.

Plot

Construction

Plot::of(mixed $data = null, Aes|array|null $aes = null): Plot

A plot of rows, columns, a phibble Table, a Laravel Collection, or Data::url(…), with optional mappings.

Mappings and data

->aes(mixed ...$mappings): Plot

Adds plot-wide aesthetic mappings: x, y, color, fill, size, shape, alpha, group, tooltip, label, …

->data(mixed $data): Plot

Geoms

->point(Aes|array|null $aes = null, mixed $data = null, int|float|null $alpha = null, int|float|null $size = null, ?string $color = null, ?string $fill = null, string|int|null $shape = null, array|int|float|bool|null $jitter = null, ?string $position = null, ?int $seed = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Scatterplot points. jitter: true (or a width, or [width, height]) displaces them randomly. seed: makes the jitter reproducible: phiz draws it in PHP and embeds it in the data, so every render places the points the same way.

->jitter(Aes|array|null $aes = null, mixed $data = null, int|float|null $width = null, int|float $height = 0, int|float|null $alpha = null, int|float|null $size = null, ?string $color = null, ?int $seed = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Points jittered by up to width/height (fraction of a band on discrete axes, data units otherwise). Without a seed the browser draws the jitter, so it changes on every render; with seed: phiz draws it in PHP and it is the same.

->line(Aes|array|null $aes = null, mixed $data = null, int|float|null $alpha = null, int|float|null $linewidth = null, ?string $color = null, array|string|null $linetype = null, ?int $downsample = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Lines connecting points in order of x. downsample: n keeps about n points per group (LTTB), in PHP.

->path(Aes|array|null $aes = null, mixed $data = null, int|float|null $alpha = null, int|float|null $linewidth = null, ?string $color = null, array|string|null $linetype = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Lines connecting points in data order.

->step(Aes|array|null $aes = null, mixed $data = null, string $direction = 'hv', int|float|null $linewidth = null, ?string $color = null, array|string|null $linetype = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Stairsteps: direction ‘hv’ (horizontal first), ‘vh’, or ‘mid’.

->area(Aes|array|null $aes = null, mixed $data = null, string $position = 'stack', int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Areas from zero, stacked by fill (position: stack, fill, identity).

->ribbon(Aes|array|null $aes = null, mixed $data = null, int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

A band between ymin and ymax (or xmin and xmax).

->bar(Aes|array|null $aes = null, mixed $data = null, string $position = 'stack', int|float|null $width = null, int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Bars of counts of x (or y), or of the y values when y is mapped. position: stack, dodge, fill, identity.

->col(Aes|array|null $aes = null, mixed $data = null, string $position = 'stack', int|float|null $width = null, int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Bars whose heights are the y values.

->histogram(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, int|float|null $boundary = null, string $position = 'stack', bool $density = false, string $compute = 'auto', int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Binned counts of x: bins (a maximum; Vega-Lite picks nice boundaries) or binwidth. density: true scales to unit area. compute: ‘server’ bins in PHP (exactly bins equal-width bins), ‘browser’ in Vega-Lite, and ‘auto’ (the default) in PHP above Config::$serverRows rows.

->freqpoly(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, int|float|null $linewidth = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Frequency polygons: binned counts drawn as lines.

->density(Aes|array|null $aes = null, mixed $data = null, int|float|null $bw = null, int|float|null $adjust = null, ?array $extent = null, ?int $n = null, bool $counts = false, ?string $position = null, int|float|null $alpha = null, ?string $fill = null, ?string $color = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Kernel density of x per group (Vega-Lite’s density transform). bw sets the bandwidth; adjust multiplies it (from R’s bw.nrd0 when bw is unset); counts: true scales to counts.

->boxplot(Aes|array|null $aes = null, mixed $data = null, int|float $coef = 1.5, bool $outliers = true, int|float|null $width = null, int|float|null $alpha = null, ?string $fill = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Tukey boxplots; coef sets the whisker extent in IQRs.

->violin(Aes|array|null $aes = null, mixed $data = null, int|float|null $bw = null, int|float|null $adjust = null, float $width = 0.9, ?int $n = null, ?string $position = null, int|float|null $alpha = null, ?string $fill = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Violins: the kernel density of y per level of a discrete x. bw sets the bandwidth, adjust multiplies R’s bw.nrd0, and width is the widest violin’s share of its band. They layer with boxplot() and jitter().

->errorbar(Aes|array|null $aes = null, mixed $data = null, int|float|null $width = null, ?string $position = null, ?string $color = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Error bars from ymin to ymax (or xmin to xmax) with end ticks; width is the tick length in pixels.

->linerange(Aes|array|null $aes = null, mixed $data = null, ?string $position = null, ?string $color = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Vertical (or horizontal) lines from ymin to ymax.

->pointrange(Aes|array|null $aes = null, mixed $data = null, ?string $position = null, ?string $color = null, int|float|null $size = null, int|float|null $linewidth = null, string|int|null $shape = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

A point at y on a line from ymin to ymax: the coefficient-plot geom. position: ‘dodge’ sets groups side by side.

->hline(Expr|array|int|float|null $yintercept = null, Aes|array|null $aes = null, mixed $data = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, mixed ...$style): Plot

Horizontal reference lines at fixed values, or at a mapped yintercept field when yintercept is null.

->vline(Expr|array|string|int|float|null $xintercept = null, Aes|array|null $aes = null, mixed $data = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, mixed ...$style): Plot

Vertical reference lines at fixed values, or at a mapped xintercept field.

->abline(array|int|float $intercept = 0, array|int|float $slope = 1, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, mixed ...$style): Plot

Lines y = intercept + slope * x across the x range (lists draw several).

->rule(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Rules at mapped positions (x, y, xend, yend).

->segment(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Line segments from (x, y) to (xend, yend).

->text(Aes|array|null $aes = null, mixed $data = null, int|float|null $size = null, ?string $color = null, int|float|null $angle = null, int|float|null $nudgeX = null, int|float|null $nudgeY = null, int|float|null $hjust = null, int|float|null $vjust = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Text from the label aesthetic. nudgeX/nudgeY offset it in pixels; angle turns it anticlockwise.

->label(Aes|array|null $aes = null, mixed $data = null, int|float|null $size = null, ?string $color = null, int|float|null $nudgeX = null, int|float|null $nudgeY = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Bold text labels.

->tile(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Heatmap tiles at discrete x and y (numbers are treated as ordered levels), filled by the fill aesthetic.

->raster(Aes|array|null $aes = null, mixed $data = null, bool $inheritAes = true, mixed ...$style): Plot

Alias of tile().

->rect(Aes|array|null $aes = null, mixed $data = null, ?string $fill = null, ?string $color = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Rectangles from xmin, xmax, ymin, ymax.

->bin2d(Aes|array|null $aes = null, mixed $data = null, array|int $bins = 30, string $compute = 'auto', bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

A 2D histogram: counts in x-by-y bins; compute works as in histogram().

->hex(Aes|array|null $aes = null, mixed $data = null, int $bins = 30, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Hexagonal bins counted in PHP, as ggplot2’s geom_hex: bins hexagons across the x range.

->smooth(Aes|array|null $aes = null, mixed $data = null, string $method = 'loess', ?bool $se = null, float $level = 0.95, float $span = 0.75, int $order = 3, int $n = 80, ?string $color = null, ?string $fill = null, int|float|null $linewidth = null, array|string|null $linetype = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

A fitted curve per group. method: loess (span sets the bandwidth), lm, poly (order), quad, log, exp, pow. With se (the default for lm, quad and poly with inline data) the fit and a level confidence band are computed in PHP; otherwise Vega-Lite fits the curve and no band is drawn.

->density2d(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, ?array $breaks = null, array|int|float|null $h = null, int|float $adjust = 1, int $n = 100, string $contourVar = 'density', ?string $color = null, int|float|null $linewidth = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Contour lines of a 2D kernel density of x and y, as ggplot2’s geom_density_2d (MASS::kde2d on an n × n grid). h sets the bandwidths ([x, y] or one for both; default MASS::bandwidth.nrd), adjust multiplies them, and bins, binwidth, or breaks set the levels (default pretty(range, 10)). contourVar: density, ndensity (scaled to a maximum of 1 per group), or count. aes(color: ‘level’) colors lines by their level.

->density2dFilled(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, ?array $breaks = null, array|int|float|null $h = null, int|float $adjust = 1, int $n = 100, string $contourVar = 'density', int|float|null $alpha = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Filled bands of a 2D kernel density between consecutive breaks, as ggplot2’s geom_density_2d_filled.

->contour(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, ?array $breaks = null, ?string $color = null, int|float|null $linewidth = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Contour lines of z over a regular grid of x and y, as ggplot2’s geom_contour; bins, binwidth, or breaks.

->contourFilled(Aes|array|null $aes = null, mixed $data = null, ?int $bins = null, int|float|null $binwidth = null, ?array $breaks = null, int|float|null $alpha = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Filled contour bands of z over a regular grid, as ggplot2’s geom_contour_filled.

->polygon(Aes|array|null $aes = null, mixed $data = null, ?string $fill = null, ?string $color = null, int|float|null $alpha = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Filled polygons through the points in data order, one per group (or fill level). Rows with null x and y start a new ring within a group; a ring drawn in the opposite direction cuts a hole.

->summary(Aes|array|null $aes = null, mixed $data = null, Closure|string|null $funData = null, Closure|string|null $fun = null, Closure|string|null $funMin = null, Closure|string|null $funMax = null, array $funArgs = [], ?string $geom = null, ?string $position = null, int|float|null $width = null, ?string $color = null, int|float|null $size = null, int|float|null $linewidth = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Summaries of y at each x, drawn with geom (pointrange by default), as ggplot2’s stat_summary. funData: mean_se (the default), mean_cl_normal, mean_sdl, median_hilow, or a callable returning [y, ymin, ymax]. fun, funMin, and funMax: mean, median, min, max, sum, sd, n, or callables of the group’s values. funArgs passes mult or conf. geom: pointrange, errorbar, linerange, crossbar, point, line, col, area, or ribbon.

->crossbar(Aes|array|null $aes = null, mixed $data = null, int|float|null $width = null, ?string $position = null, ?string $color = null, ?string $fill = null, int|float|null $linewidth = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

A box from ymin to ymax with a line at y, as ggplot2’s geom_crossbar; width is a share of the band.

->ellipse(Aes|array|null $aes = null, mixed $data = null, string $type = 't', float $level = 0.95, int $segments = 51, string $geom = 'path', ?string $color = null, ?string $fill = null, int|float|null $linewidth = null, array|string|null $linetype = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Confidence ellipses per group, as ggplot2’s stat_ellipse: type ‘t’ (a robust multivariate t fit), ‘norm’, or ‘euclid’ (a circle of radius level), at level. geom: ‘polygon’ fills them.

->count(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Points sized by how many rows share each x and y, as ggplot2’s geom_count.

->annotate(string $geom, mixed $x = null, mixed $y = null, mixed $xmin = null, mixed $xmax = null, mixed $ymin = null, mixed $ymax = null, mixed $xend = null, mixed $yend = null, mixed $label = null, mixed ...$style): Plot

A layer of fixed values rather than data, as ggplot2’s annotate(): annotate(‘text’, x: 4, y: 40, label: ‘Note’), annotate(‘rect’, xmin: 2, xmax: 3, ymin: -INF …). Positions are numbers, dates, or levels, or lists of them for several marks. Annotations ignore the plot’s mappings and appear in every facet panel. geom: text, label, point, segment, rect, pointrange, linerange, errorbar, crossbar, or rule.

->curve(callable $fn, int|float $from, int|float $to, int $n = 101, Aes|array|null $aes = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, mixed ...$style): Plot

A function of x drawn from from to to, as ggplot2’s geom_function.

->rug(Aes|array|null $aes = null, mixed $data = null, ?string $sides = null, int $length = 8, ?string $color = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Marginal ticks: sides ‘b’ (bottom, for x), ‘l’ (left, for y), or ‘bl’; length in pixels.

->ecdf(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Empirical cumulative distribution of x per group.

->qq(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, int|float|null $size = null, int|float|null $alpha = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Normal quantile-quantile points of the sample aesthetic.

->qqLine(Aes|array|null $aes = null, mixed $data = null, ?string $color = null, array|string|null $linetype = null, int|float|null $linewidth = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

The QQ reference line through the sample’s quartiles.

->arc(Aes|array|null $aes = null, mixed $data = null, int|float|null $innerRadius = null, ?string $color = null, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style): Plot

Pie (or donut, with innerRadius in pixels) slices sized by theta, or counts of fill.

->pie(Aes|array|null $aes = null, mixed $data = null, int|float|null $innerRadius = null, mixed ...$style): Plot

Alias of arc().

->layer(array $spec): Plot

A raw Vega-Lite layer, used as given.

->geom(string $geom, Aes|array|null $aes = null, mixed $data = null, array $params = [], array $style = [], bool $inheritAes = true, array|string|null $filter = null, array $raw = []): Plot

Adds a geom by name with options: the generic form behind the geom methods.

Scales

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

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

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

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

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

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

->scaleFill(mixed ...$options): Plot
->scaleSize(mixed ...$options): Plot
->scaleShape(mixed ...$options): Plot
->scaleOpacity(mixed ...$options): Plot
->scaleLinetype(mixed ...$options): Plot
->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()).

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

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

Coordinates and facets

->coordFlip(bool $flip = true): Plot

Swaps the x and y channels, so mappings stay as written while the plot turns sideways.

->coordPolar(string $theta = 'x', float $start = 0.0, int $direction = 1, int|float $innerRadius = 0): Plot

Polar coordinates for bar() and col() layers, as ggplot2’s coord_polar. theta: ‘y’ turns stacked bars into a pie (map x to a constant, or leave it out; innerRadius in pixels makes a donut), and ‘x’ turns bars over a discrete x into a rose of equal angles with radius y. start rotates the first slice clockwise from twelve o’clock, in radians; direction -1 runs anticlockwise.

->coordFixed(int|float $ratio = 1): Plot

A fixed aspect ratio, as ggplot2’s coord_fixed: one unit of y takes ratio times the length of one unit of x. The panel’s height follows from the width (300 pixels unless set) and the data ranges, which are kept exact.

->coordCartesian(?array $xlim = null, ?array $ylim = null): Plot

Zooms to fixed domains, clipping marks outside them.

->facetWrap(array|string $facets, ?int $ncol = null, ?int $nrow = null, string $scales = 'fixed', array|string $labeller = 'value', array $header = []): Plot

Small multiples wrapped into rows. scales: fixed, free, free_x, free_y. With several fields the panels are their combinations. labeller: ‘both’ labels panels “field: value”, as ggplot2’s label_both.

->facetGrid(?string $rows = null, ?string $cols = null, string $scales = 'fixed', array|string $labeller = 'value', array $header = []): Plot

A grid of panels by rows and/or cols fields.

Labels, theme, size

->labs(mixed ...$labels): Plot

Titles: title, subtitle, caption, and one per aesthetic (x, y, color, fill, size, shape, …). A facet field’s name sets its panel header title. Null removes a title. The caption sits below the plot; theme() styles it.

->title(?string $title, ?string $subtitle = null): Plot
->theme(?string $preset = null, int|float|null $baseSize = null, ?string $font = null, ?string $legendPosition = null, ?string $background = null, ?string $panelBackground = null, ?string $panelBorder = null, ?bool $grid = null, ?string $titleAnchor = null, int|float|null $padding = null, int|float|null $xLabelAngle = null, int|float|null $yLabelAngle = null, ?string $legendDirection = null, ?bool $legendTitle = null, ?bool $axisLine = null, ?bool $ticks = null, ?string $gridColor = null, ?string $textColor = null, int|float|null $captionSize = null, ?string $captionColor = null, ?string $captionAnchor = null, array $config = []): Plot

A theme preset (gray, bw, linedraw, minimal, classic, light, dark, void, vega) and/or individual options; config is raw Vega-Lite config merged last. Successive calls build on each other. xLabelAngle and yLabelAngle turn axis labels anticlockwise, as element_text(angle =); legendTitle: false, axisLine, and ticks switch those parts. captionSize, captionColor, and captionAnchor (start, middle, or end) style labs(caption:).

->size(string|int|null $width = null, string|int|null $height = null): Plot

Width and height in pixels (per panel when faceted); ‘container’ fills the parent element’s width.

->width(string|int $width): Plot
->height(string|int $height): Plot
->description(string $description): Plot

Interaction

->tooltip(array|string|bool $fields = true): Plot

Tooltips on every layer: true shows the encoded fields, a list shows those fields.

->interactive(array $encodings = [0 => 'x',1 => 'y'], string $name = 'zoom'): Plot

Pan and zoom by dragging and scrolling (scales bound to an interval selection).

->brush(string $name = 'brush', array $encodings = [0 => 'x'], ?string $unselected = '#cccccc', string $channel = 'color'): Plot

A drag-to-select interval named $name. Unselected marks of the first layer turn $unselected; other layers can react with filter: [‘param’ => $name], and linked plots in a composition share it.

->highlight(string $aesthetic = 'color', string $name = 'highlight', ?string $bind = 'legend', float $opacity = 0.15): Plot

Click legend entries (or marks, with bind: null) to highlight their group; others fade to $opacity.

->slider(string $name, int|float $min, int|float $max, int|float|null $step = null, int|float|null $value = null, ?string $label = null): Plot

A slider bound to a parameter; use expr($name) in geoms or a filter to react to it.

->dropdown(string $name, array $options, mixed $value = null, ?string $label = null): Plot

A dropdown bound to a parameter.

->param(string $name, mixed $value = null, ?array $bind = null, ?string $expr = null): Plot

A Vega-Lite parameter: a value, optionally bound to an input, or an expr.

->select(array $param): Plot

A raw selection parameter, attached to the first layer.

Escape hatches

->transform(array ...$transforms): Plot

Vega-Lite transforms applied to the data before every layer.

->raw(array $spec): Plot

Raw Vega-Lite merged into the top-level spec last (nested objects merge; lists and scalars replace).

->apply(callable ...$fns): Plot

Applies a function to the plot: pipe-friendly composition of reusable plot fragments.

->toArray(): array
->toSpec(): array

Aesthetics

x, y, xmin, xmax, ymin, ymax, xend, yend, color (or colour), fill, size, shape, opacity (or alpha), linetype, group, detail, tooltip, label (or text), order, href, theta, radius, xintercept, yintercept, sample, key, and description.

Functions

Most functions in the Phiz\ namespace return a closure that applies the method of the same name, for the pipe operator and apply(). They take the same arguments as that method.

  • aes(mixed ...$mappings): Aes: Aesthetic mappings: aes(x: ‘displ’, y: ‘hwy’, color: ‘class’).
  • ggplot(mixed $data = null, Aes|array|null $mapping = null): Plot: A plot of data with optional mappings.
  • field(string $name, ?string $type = null, mixed ...$properties): Field: A field with an explicit type or other Vega-Lite field-definition properties.
  • factor(string $name, ?array $levels = null): Field: A field treated as discrete categories, like R’s factor(cyl). Levels set the order.
  • calc(string $expression, string $as, ?string $type = null): Field: A field computed from a Vega expression: calc(‘datum.hwy - datum.cty’, as: ‘gap’).
  • expr(string $expression): Expr: A Vega expression, such as a slider parameter’s name.
  • geom_point(mixed ...$args): Closure: ->point() as a closure, for the pipe operator and apply().
  • geom_jitter(mixed ...$args): Closure: ->jitter() as a closure, for the pipe operator and apply().
  • geom_line(mixed ...$args): Closure: ->line() as a closure, for the pipe operator and apply().
  • geom_path(mixed ...$args): Closure: ->path() as a closure, for the pipe operator and apply().
  • geom_step(mixed ...$args): Closure: ->step() as a closure, for the pipe operator and apply().
  • geom_area(mixed ...$args): Closure: ->area() as a closure, for the pipe operator and apply().
  • geom_ribbon(mixed ...$args): Closure: ->ribbon() as a closure, for the pipe operator and apply().
  • geom_bar(mixed ...$args): Closure: ->bar() as a closure, for the pipe operator and apply().
  • geom_col(mixed ...$args): Closure: ->col() as a closure, for the pipe operator and apply().
  • geom_histogram(mixed ...$args): Closure: ->histogram() as a closure, for the pipe operator and apply().
  • geom_freqpoly(mixed ...$args): Closure: ->freqpoly() as a closure, for the pipe operator and apply().
  • geom_density(mixed ...$args): Closure: ->density() as a closure, for the pipe operator and apply().
  • geom_boxplot(mixed ...$args): Closure: ->boxplot() as a closure, for the pipe operator and apply().
  • geom_violin(mixed ...$args): Closure: ->violin() as a closure, for the pipe operator and apply().
  • geom_errorbar(mixed ...$args): Closure: ->errorbar() as a closure, for the pipe operator and apply().
  • geom_linerange(mixed ...$args): Closure: ->linerange() as a closure, for the pipe operator and apply().
  • geom_pointrange(mixed ...$args): Closure: ->pointrange() as a closure, for the pipe operator and apply().
  • geom_hline(mixed ...$args): Closure: ->hline() as a closure, for the pipe operator and apply().
  • geom_vline(mixed ...$args): Closure: ->vline() as a closure, for the pipe operator and apply().
  • geom_abline(mixed ...$args): Closure: ->abline() as a closure, for the pipe operator and apply().
  • geom_rule(mixed ...$args): Closure: ->rule() as a closure, for the pipe operator and apply().
  • geom_segment(mixed ...$args): Closure: ->segment() as a closure, for the pipe operator and apply().
  • geom_text(mixed ...$args): Closure: ->text() as a closure, for the pipe operator and apply().
  • geom_label(mixed ...$args): Closure: ->label() as a closure, for the pipe operator and apply().
  • geom_tile(mixed ...$args): Closure: ->tile() as a closure, for the pipe operator and apply().
  • geom_raster(mixed ...$args): Closure: ->raster() as a closure, for the pipe operator and apply().
  • geom_rect(mixed ...$args): Closure: ->rect() as a closure, for the pipe operator and apply().
  • geom_bin2d(mixed ...$args): Closure: ->bin2d() as a closure, for the pipe operator and apply().
  • geom_hex(mixed ...$args): Closure: ->hex() as a closure, for the pipe operator and apply().
  • geom_smooth(mixed ...$args): Closure: ->smooth() as a closure, for the pipe operator and apply().
  • geom_function(mixed ...$args): Closure: ->curve() as a closure, for the pipe operator and apply().
  • geom_rug(mixed ...$args): Closure: ->rug() as a closure, for the pipe operator and apply().
  • stat_ecdf(mixed ...$args): Closure: ->ecdf() as a closure, for the pipe operator and apply().
  • stat_qq(mixed ...$args): Closure: ->qq() as a closure, for the pipe operator and apply().
  • stat_qq_line(mixed ...$args): Closure: ->qqLine() as a closure, for the pipe operator and apply().
  • geom_arc(mixed ...$args): Closure: ->arc() as a closure, for the pipe operator and apply().
  • geom_polygon(mixed ...$args): Closure: ->polygon() as a closure, for the pipe operator and apply().
  • stat_summary(mixed ...$args): Closure: ->summary() as a closure, for the pipe operator and apply().
  • geom_crossbar(mixed ...$args): Closure: ->crossbar() as a closure, for the pipe operator and apply().
  • geom_count(mixed ...$args): Closure: ->count() as a closure, for the pipe operator and apply().
  • stat_ellipse(mixed ...$args): Closure: ->ellipse() as a closure, for the pipe operator and apply().
  • annotate(string $geom, mixed ...$args): Closure: ->annotate() as a closure, for the pipe operator and apply().
  • geom_density_2d(mixed ...$args): Closure: ->density2d() as a closure, for the pipe operator and apply().
  • stat_density_2d(mixed ...$args): Closure: ->density2d() as a closure, for the pipe operator and apply().
  • geom_density_2d_filled(mixed ...$args): Closure: ->density2dFilled() as a closure, for the pipe operator and apply().
  • stat_density_2d_filled(mixed ...$args): Closure: ->density2dFilled() as a closure, for the pipe operator and apply().
  • geom_contour(mixed ...$args): Closure: ->contour() as a closure, for the pipe operator and apply().
  • stat_contour(mixed ...$args): Closure: ->contour() as a closure, for the pipe operator and apply().
  • geom_contour_filled(mixed ...$args): Closure: ->contourFilled() as a closure, for the pipe operator and apply().
  • scale_x(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_x_continuous(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y_continuous(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_x_log10(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y_log10(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_x_sqrt(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y_sqrt(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_x_reverse(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y_reverse(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_x_date(mixed ...$args): Closure: ->scaleX() as a closure, for the pipe operator and apply().
  • scale_y_date(mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • scale_color(mixed ...$args): Closure: ->scaleColor() as a closure, for the pipe operator and apply().
  • scale_fill(mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_size(mixed ...$args): Closure: ->scaleSize() as a closure, for the pipe operator and apply().
  • scale_shape(mixed ...$args): Closure: ->scaleShape() as a closure, for the pipe operator and apply().
  • scale_alpha(mixed ...$args): Closure: ->scaleOpacity() as a closure, for the pipe operator and apply().
  • scale_linetype(mixed ...$args): Closure: ->scaleLinetype() as a closure, for the pipe operator and apply().
  • scale_color_manual(array $values, mixed ...$args): Closure: Manual colors: a level => color map, or colors in level order.
  • scale_fill_manual(array $values, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_scheme(string $scheme, mixed ...$args): Closure: Vega color schemes by name, such as ‘viridis’, ‘blues’, ‘set2’, ‘dark2’, ‘tableau10’.
  • scale_fill_scheme(string $scheme, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_viridis(string $option = 'viridis', mixed ...$args): Closure: ->scaleColor() as a closure, for the pipe operator and apply().
  • scale_fill_viridis(string $option = 'viridis', mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_brewer(string $palette = 'set1', mixed ...$args): Closure: ->scaleColor() as a closure, for the pipe operator and apply().
  • scale_fill_brewer(string $palette = 'set1', mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(string $low = '#132B43', string $high = '#56B1F7', mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(string $low = '#832424', string $mid = '#FFFFFF', string $high = '#3A3A98', int|float $midpoint = 0, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(string $palette, int $direction = 1): array|string: A ColorBrewer scheme, reversed when direction is -1.
  • 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(string $option = 'D', float $begin = 0.0, float $end = 1.0, int $direction = 1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_viridis_c(string $option = 'D', float $begin = 0.0, float $end = 1.0, int $direction = 1, mixed ...$args): Closure: ->scaleColor() as a closure, for the pipe operator and apply().
  • scale_fill_viridis_c(string $option = 'D', float $begin = 0.0, float $end = 1.0, int $direction = 1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_viridis_b(string $option = 'D', float $begin = 0.0, float $end = 1.0, int $direction = 1, mixed ...$args): Closure: ->scaleColor() as a closure, for the pipe operator and apply().
  • scale_fill_viridis_b(string $option = 'D', float $begin = 0.0, float $end = 1.0, int $direction = 1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(string $palette = 'Blues', int $direction = -1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(string $palette = 'Blues', int $direction = -1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_color_gradientn(array $colors, mixed ...$args): Closure: A gradient through several colors, as ggplot2’s scale_colour_gradientn.
  • scale_fill_gradientn(array $colors, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(float $start = 0.2, float $end = 0.8, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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(array $h = [0 => 15,1 => 375], int|float $c = 100, int|float $l = 65, int|float $hStart = 0, int $direction = 1, mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • 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_fill_identity(mixed ...$args): Closure: ->scaleFill() as a closure, for the pipe operator and apply().
  • scale_x_discrete(?array $limits = null, mixed ...$args): Closure: Discrete position scales: limits orders (and subsets) the levels, labels renames them.
  • scale_y_discrete(?array $limits = null, mixed ...$args): Closure: ->scaleY() as a closure, for the pipe operator and apply().
  • guides(mixed ...$guides): Closure: Axis or legend options per aesthetic, as ggplot2’s guides(): guides(color: ‘none’, x: guide_axis(angle: 45)).
  • 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(?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(mixed ...$args): array
  • 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(): bool
  • 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(int|float|null $accuracy = null, int|float $scale = 1, string $prefix = '', string $suffix = ''): Label: Thousands separators, as scales::label_comma().
  • 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(int|float|null $accuracy = null, int|float $scale = 1, string $prefix = '$', string $suffix = ''): Label: Currency, as scales::label_dollar().
  • label_scientific(int $digits = 3): Label: Scientific notation with digits significant digits, as scales::label_scientific().
  • label_date(string $format = '%Y-%m-%d'): Label: Dates and times with a strftime-style format, as scales::label_date().
  • xlim(string|int|float $min, string|int|float $max): Closure: ->xlim() as a closure, for the pipe operator and apply().
  • ylim(string|int|float $min, string|int|float $max): Closure: ->ylim() as a closure, for the pipe operator and apply().
  • coord_flip(): Closure: ->coordFlip() as a closure, for the pipe operator and apply().
  • coord_polar(mixed ...$args): Closure: ->coordPolar() as a closure, for the pipe operator and apply().
  • coord_fixed(int|float $ratio = 1): Closure: ->coordFixed() as a closure, for the pipe operator and apply().
  • coord_equal(int|float $ratio = 1): Closure: ->coordFixed() as a closure, for the pipe operator and apply().
  • coord_cartesian(mixed ...$args): Closure: ->coordCartesian() as a closure, for the pipe operator and apply().
  • facet_wrap(mixed ...$args): Closure: ->facetWrap() as a closure, for the pipe operator and apply().
  • facet_grid(mixed ...$args): Closure: ->facetGrid() as a closure, for the pipe operator and apply().
  • labs(mixed ...$args): Closure: ->labs() as a closure, for the pipe operator and apply().
  • ggtitle(?string $title, ?string $subtitle = null): Closure: ->title() as a closure, for the pipe operator and apply().
  • xlab(?string $title): Closure: ->labs() as a closure, for the pipe operator and apply().
  • ylab(?string $title): Closure: ->labs() as a closure, for the pipe operator and apply().
  • theme(mixed ...$args): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_gray(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_grey(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_bw(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_minimal(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_classic(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_light(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_dark(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_void(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • theme_linedraw(int|float $baseSize = 11): Closure: ->theme() as a closure, for the pipe operator and apply().
  • size(string|int|null $width = null, string|int|null $height = null): Closure: ->size() as a closure, for the pipe operator and apply().
  • tooltip(array|string|bool $fields = true): Closure: ->tooltip() as a closure, for the pipe operator and apply().
  • interactive(mixed ...$args): Closure: ->interactive() as a closure, for the pipe operator and apply().
  • brush(mixed ...$args): Closure: ->brush() as a closure, for the pipe operator and apply().
  • highlight(mixed ...$args): Closure: ->highlight() as a closure, for the pipe operator and apply().
  • coefplot(array $fits, mixed ...$options): Plot: Coefficient plot of one fit, or of several keyed by label (dodged side by side).
  • residual_plot(array $fit): Plot
  • qq_plot(array $fitOrValues, bool $standardize = false): Plot
  • fitted_plot(array $fit, ?array $observed = null): Plot
  • scale_location_plot(array $fit): Plot
  • diagnostic_plots(array $fit, mixed ...$options): Compose
  • effect_plot(array $fit, mixed $data, string $x, mixed ...$options): Plot: Predicted values with confidence bands as x varies (by levels of $by), other variables held at typical values.
  • predictions(array $fit, array $grid, mixed ...$options): array
  • interval_plot(array $draws, mixed ...$options): Plot: Posterior intervals from draws columns or a summary, as bayesplot’s mcmc_intervals.
  • marginal_means(array $fit, mixed $data, string $factor, mixed ...$options): Plot: Estimated marginal means of a factor with confidence intervals, as emmeans.
  • random_effects_plot(array $fit, mixed $data = null, mixed ...$options): Plot: A caterpillar plot of a mixed model’s random effects with conditional intervals, as lme4’s dotplot(ranef()).

Other classes

Class Purpose
Compose beside, stack, and grid compositions
Data from, url, and named data sources
Field field definitions and shorthand parsing
Scale, Theme, Style scale, theme, and style translation
Palette ggplot2’s hue palette and R’s hcl() colors
Html, Assets HTML output and the pinned browser libraries
Export vl-convert export
Datasets mpg, mtcars, economics, and faithful
Bin histograms, 2D and hexagonal bins, LTTB downsampling, and sampling in PHP
Config large-data thresholds: $serverRows and $warnRows
Stats\Charts the statistics helpers
Stats\Fit least squares, smoothing bands, and normal and t quantiles

Compose

Compose::beside(Chart ...$charts): Compose
Compose::stack(Chart ...$charts): Compose
Compose::grid(array $charts, int $columns = 2): Compose

A grid filled row by row with the given number of columns.

->title(string $title, ?string $subtitle = null): Compose
->theme(?string $preset = null, mixed ...$options): Compose

A theme preset and options for the whole composition, as Plot::theme().

->resolve(array $resolve): Compose

Shares or separates scales, axes, and legends across the plots, e.g. [‘scale’ => [‘color’ => ‘independent’]].

->raw(array $spec): Compose
->toArray(): array
->toSpec(): array

Data

Data::from(mixed $data): Data
Data::url(string $url, ?string $type = null, ?array $parse = null): Data

Data that Vega-Lite fetches from a URL (CSV, TSV, JSON); types can’t be inferred, so use ‘field:Q’ shorthand.

Data::named(string $name): Data

A named data source the page supplies at runtime (vega-embed’s view.data(name, rows)).

->isInline(): bool
->isEmpty(): bool
->count(): int

The number of inline rows, without building them.

->source(): mixed

What the binning helpers read: the table, the columns, or the rows.

->toSpec(): array
->fields(): array
->has(string $field): bool
->column(string $field): array

A field’s values, JSON-safe, read from the table or columns without building rows.

->type(string $field): ?string

The Vega-Lite measurement type of a field: quantitative when every non-null value is a number, temporal when every value is an ISO date string, nominal otherwise. Null for non-inline data or an all-null column.

->levels(string $field): array

Distinct non-null values of a field in first-seen order.

->withRows(array $rows): Data
Data::value(mixed $value): mixed

Export

Export::find(): ?string

The vl-convert binary path, or null when none is found.

Export::available(): bool
->svg(Chart|array $chart): string
->png(Chart|array $chart, float $scale = 2.0, ?int $ppi = null): string

PNG bytes; scale multiplies the pixel size (2 for high-DPI screens), ppi sets the embedded resolution.

->jpeg(Chart|array $chart, float $scale = 2.0, ?int $quality = null): string
->pdf(Chart|array $chart): string
->vega(Chart|array $chart): array

The compiled Vega (not Vega-Lite) spec.

->save(Chart|array $chart, string $path, float $scale = 2.0): string

Writes the chart to a file whose extension picks the format: svg, png, jpg/jpeg, pdf, html, or json.

Html

Html::container(Chart|array $chart, array $options = [], array $attributes = []): string

The container element for a chart.

Html::deferred(string $url, array $options = [], array $attributes = [], string $text = 'Vega-Lite specification'): string

A container that loads its spec from a URL when it scrolls into view, for pages with many charts. The URL is the href of a link inside the container, so the page still links to each spec without JavaScript, and tools that rewrite links move the spec files with the page.

Html::embed(Chart|array $chart, array $options = [], Assets|false|null $assets = null, array $attributes = []): string

A self-contained fragment: the container plus script tags (null assets means the pinned CDN copies).

Html::page(Chart|array|null $chart, ?string $title = null, array $options = [], ?Assets $assets = null, string $body = ''): string
Html::attributes(array $attributes): string

Bin

Bin::histogram(mixed $source, string $x, int $bins = 30, int|float|null $binwidth = null, int|float|null $boundary = null, ?array $limits = null, array $groups = []): array

Equal-width bins of x: rows with x0, x1, count, and density (count / (n * width)), per group.

Bin::grid(mixed $source, string $x, string $y, array|int $bins = 30, ?array $xlim = null, ?array $ylim = null, array $groups = []): array

Counts in a grid of x-by-y rectangles: rows with x_start, x_end, y_start, y_end (named after the fields) and count. Empty cells are omitted.

Bin::hex(mixed $source, string $x, string $y, int $bins = 30, ?array $xlim = null, ?array $ylim = null, float $aspect = 1.0, array $groups = []): array

Counts in a hexagonal grid, as ggplot2’s geom_hex: rows with the hexagon centers (under the x and y names) and count. bins hexagons span the x range; aspect (height / width of the panel in pixels) keeps them regular on screen.

Bin::lttb(array $rows, string $x, string $y, int $threshold = 1000, array $groups = []): array

Downsamples a line to about $threshold points with Largest-Triangle-Three-Buckets, which keeps the visual shape (peaks and troughs). Rows are sorted by x; groups are downsampled separately.

Bin::sample(mixed $source, int $n, int $seed = 1): array

A uniform random sample of n rows (reservoir sampling, one pass), reproducible with a seed.

Bin::range(mixed $source, string $field): array

The [min, max] of a numeric field, padded when every value is equal.

Bin::values(mixed $source, array $fields): Generator

The values of the named fields, one list per record.

From phpstats/phiz@bc7ed3e.