Geoms API
On this page
-
point()
- jitter()
- line()
- path()
- step()
- area()
- ribbon()
- bar()
- col()
- histogram()
- freqpoly()
- density()
- boxplot()
- violin()
- errorbar()
- linerange()
- pointrange()
- hline()
- vline()
- abline()
- rule()
- segment()
- text()
- label()
- tile()
- raster()
- rect()
- bin2d()
- hex()
- smooth()
- density2d()
- density2dFilled()
- contour()
- contourFilled()
- polygon()
- summary()
- crossbar()
- ellipse()
- count()
- annotate()
- curve()
- rug()
- ecdf()
- qq()
- qqLine()
- arc()
- pie()
- layer()
- geom()
- Functions
Each geom method adds a layer. Most geoms take aes (the layer’s own mappings) and data (the layer’s own data) as their first arguments, inheritAes (false ignores the plot’s mappings), filter (a Vega expression or selection predicate), and fixed visual properties by their ggplot2 names, such as alpha, color, and linewidth, or as any Vega-Lite mark property, such as strokeWidth: 2. Geoms shows each geom with an example.
Methods: point() · jitter() · line() · path() · step() · area() · ribbon() · bar() · col() · histogram() · freqpoly() · density() · boxplot() · violin() · errorbar() · linerange() · pointrange() · hline() · vline() · abline() · rule() · segment() · text() · label() · tile() · raster() · rect() · bin2d() · hex() · smooth() · density2d() · density2dFilled() · contour() · contourFilled() · polygon() · summary() · crossbar() · ellipse() · count() · annotate() · curve() · rug() · ecdf() · qq() · qqLine() · arc() · pie() · layer() · geom()
Functions: geom_point() · geom_jitter() · geom_line() · geom_path() · geom_step() · geom_area() · geom_ribbon() · geom_bar() · geom_col() · geom_histogram() · geom_freqpoly() · geom_density() · geom_boxplot() · geom_violin() · geom_errorbar() · geom_linerange() · geom_pointrange() · geom_hline() · geom_vline() · geom_abline() · geom_rule() · geom_segment() · geom_text() · geom_label() · geom_tile() · geom_raster() · geom_rect() · geom_bin2d() · geom_hex() · geom_smooth() · geom_function() · geom_rug() · stat_ecdf() · stat_qq() · stat_qq_line() · geom_arc() · geom_polygon() · stat_summary() · geom_crossbar() · geom_count() · stat_ellipse() · annotate() · geom_density_2d() · stat_density_2d() · geom_density_2d_filled() · stat_density_2d_filled() · geom_contour() · stat_contour() · geom_contour_filled()
point()
->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,): PlotScatterplot 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.
Function: geom_point().
jitter()
->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,): PlotPoints 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.
Function: geom_jitter().
line()
->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,): PlotLines connecting points in order of x. downsample: n keeps about n points per group (LTTB), in PHP.
Function: geom_line().
path()
->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,): PlotLines connecting points in data order.
Function: geom_path().
step()
->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,): PlotStairsteps: direction ‘hv’ (horizontal first), ‘vh’, or ‘mid’.
Function: geom_step().
area()
->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,): PlotAreas from zero, stacked by fill (position: stack, fill, identity).
Function: geom_area().
ribbon()
->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,): PlotA band between ymin and ymax (or xmin and xmax).
Function: geom_ribbon().
bar()
->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,): PlotBars of counts of x (or y), or of the y values when y is mapped. position: stack, dodge, fill, identity.
Function: geom_bar().
col()
->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,): PlotBars whose heights are the y values.
Function: geom_col().
histogram()
->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,): PlotBinned 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.
Function: geom_histogram().
freqpoly()
->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,): PlotFrequency polygons: binned counts drawn as lines.
Function: geom_freqpoly().
density()
->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,): PlotKernel 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.
Function: geom_density().
boxplot()
->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,): PlotTukey boxplots; coef sets the whisker extent in IQRs.
Function: geom_boxplot().
violin()
->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,): PlotViolins: 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().
Function: geom_violin().
errorbar()
->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,): PlotError bars from ymin to ymax (or xmin to xmax) with end ticks; width is the tick length in pixels.
Function: geom_errorbar().
linerange()
->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,): PlotVertical (or horizontal) lines from ymin to ymax.
Function: geom_linerange().
pointrange()
->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,): PlotA point at y on a line from ymin to ymax: the coefficient-plot geom. position: ‘dodge’ sets groups side by side.
Function: geom_pointrange().
hline()
->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,): PlotHorizontal reference lines at fixed values, or at a mapped yintercept field when yintercept is null.
Function: geom_hline().
vline()
->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,): PlotVertical reference lines at fixed values, or at a mapped xintercept field.
Function: geom_vline().
abline()
->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,): PlotLines y = intercept + slope * x across the x range (lists draw several).
Function: geom_abline().
rule()
->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,): PlotRules at mapped positions (x, y, xend, yend).
Function: geom_rule().
segment()
->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,): PlotLine segments from (x, y) to (xend, yend).
Function: geom_segment().
text()
->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,): PlotText from the label aesthetic. nudgeX/nudgeY offset it in pixels; angle turns it anticlockwise.
Function: geom_text().
label()
->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,): PlotText from the label aesthetic in bold, standing in for geom_label(); Vega-Lite draws no box behind it.
Function: geom_label().
tile()
->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,): PlotHeatmap tiles at discrete x and y (numbers are treated as ordered levels), filled by the fill aesthetic.
Function: geom_tile().
raster()
->raster( Aes|array|null $aes = null, mixed $data = null, bool $inheritAes = true, mixed ...$style,): PlotHeatmap tiles, as tile() draws them; ggplot2’s geom_raster() name.
Function: geom_raster().
rect()
->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,): PlotRectangles from xmin, xmax, ymin, ymax.
Function: geom_rect().
bin2d()
->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,): PlotA 2D histogram: counts in x-by-y bins; compute works as in histogram().
Function: geom_bin2d().
hex()
->hex( Aes|array|null $aes = null, mixed $data = null, int $bins = 30, bool $inheritAes = true, array|string|null $filter = null, mixed ...$style,): PlotHexagonal bins counted in PHP, as ggplot2’s geom_hex: bins hexagons across the x range.
Function: geom_hex().
smooth()
->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,): PlotA 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.
Function: geom_smooth().
density2d()
->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,): PlotContour 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.
Functions: geom_density_2d(), stat_density_2d().
density2dFilled()
->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,): PlotFilled bands of a 2D kernel density between consecutive breaks, as ggplot2’s geom_density_2d_filled.
Functions: geom_density_2d_filled(), stat_density_2d_filled().
contour()
->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,): PlotContour lines of z over a regular grid of x and y, as ggplot2’s geom_contour; bins, binwidth, or breaks.
Functions: geom_contour(), stat_contour().
contourFilled()
->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,): PlotFilled contour bands of z over a regular grid, as ggplot2’s geom_contour_filled.
Function: geom_contour_filled().
polygon()
->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,): PlotFilled 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.
Function: geom_polygon().
summary()
->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,): PlotSummaries 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.
Function: stat_summary().
crossbar()
->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,): PlotA box from ymin to ymax with a line at y, as ggplot2’s geom_crossbar; width is a share of the band.
Function: geom_crossbar().
ellipse()
->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,): PlotConfidence 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.
Function: stat_ellipse().
count()
->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,): PlotPoints sized by how many rows share each x and y, as ggplot2’s geom_count.
Function: geom_count().
annotate()
->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,): PlotA 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.
Function: annotate().
curve()
->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,): PlotA function of x drawn from from to to, as ggplot2’s geom_function.
Function: geom_function().
rug()
->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,): PlotMarginal ticks: sides ‘b’ (bottom, for x), ‘l’ (left, for y), or ‘bl’; length in pixels.
Function: geom_rug().
ecdf()
->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,): PlotEmpirical cumulative distribution of x per group.
Function: stat_ecdf().
qq()
->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,): PlotNormal quantile-quantile points of the sample aesthetic.
Function: stat_qq().
qqLine()
->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,): PlotThe QQ reference line through the sample’s quartiles.
Function: stat_qq_line().
arc()
->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,): PlotPie (or donut, with innerRadius in pixels) slices sized by theta, or counts of fill.
Function: geom_arc().
pie()
->pie( Aes|array|null $aes = null, mixed $data = null, int|float|null $innerRadius = null, mixed ...$style,): PlotPie or donut slices, as arc() draws them; innerRadius in pixels makes a donut.
layer()
->layer(array $spec): PlotA raw Vega-Lite layer, used as given.
geom()
->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 = [],): PlotAdds a geom by name with options: the generic form behind the geom methods.
Functions
annotate()
annotate(string $geom, mixed ...$args): ClosureThe pipe form of ->annotate().