Labels and themes API
On this page
These methods set the titles, axis and legend labels, caption, theme, and size of a plot. Themes shows the theme presets and options.
Methods: labs() · title() · theme() · size() · width() · height() · description()
Functions: labs() · ggtitle() · xlab() · ylab() · theme() · theme_gray() · theme_grey() · theme_bw() · theme_minimal() · theme_classic() · theme_light() · theme_dark() · theme_void() · theme_linedraw() · size()
labs()
->labs(mixed ...$labels): PlotTitles: 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()
->title(?string $title, ?string $subtitle = null): PlotThe title and subtitle, as ggplot2’s ggtitle(); null removes the title.
Function: ggtitle().
theme()
->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 = [],): PlotA 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:).
Functions: theme(), theme_gray(), theme_grey(), theme_bw(), theme_minimal(), theme_classic(), theme_light(), theme_dark(), theme_void(), theme_linedraw().
size()
->size(string|int|null $width = null, string|int|null $height = null): PlotWidth and height in pixels (per panel when faceted); ‘container’ fills the parent element’s width.
Function: size().
width()
->width(string|int $width): PlotThe width in pixels (per panel when faceted), or ‘container’ to fill the parent element.
height()
->height(string|int $height): PlotThe height in pixels (per panel when faceted), or ‘container’ to fill the parent element.
description()
->description(string $description): PlotA text description of the chart, which vega-embed uses as its accessible name.
Functions
ggtitle()
ggtitle(?string $title, ?string $subtitle = null): ClosureThe pipe form of ->title().
xlab()
xlab(?string $title): ClosureThe x axis title, as ggplot2’s xlab(); null removes it.
ylab()
ylab(?string $title): ClosureThe y axis title, as ggplot2’s ylab(); null removes it.
theme_gray()
theme_gray(int|float $baseSize = 11): ClosureThe gray preset, ggplot2’s default theme; baseSize sets the base font size in points.
theme_grey()
theme_grey(int|float $baseSize = 11): ClosureAn alias of theme_gray().
theme_bw()
theme_bw(int|float $baseSize = 11): ClosureThe bw preset: a white panel with a dark border and gray grid lines.
theme_minimal()
theme_minimal(int|float $baseSize = 11): ClosureThe minimal preset: grid lines only, with no panel background or border.
theme_classic()
theme_classic(int|float $baseSize = 11): ClosureThe classic preset: axis lines and no grid.
theme_light()
theme_light(int|float $baseSize = 11): ClosureThe light preset: light gray grid lines and a light gray border.
theme_dark()
theme_dark(int|float $baseSize = 11): ClosureThe dark preset: a dark background and panel, with light text and grid lines.
theme_void()
theme_void(int|float $baseSize = 11): ClosureThe void preset: no axes, grid, or background.
theme_linedraw()
theme_linedraw(int|float $baseSize = 11): ClosureThe linedraw preset: fine black grid lines and a black border.
size()
size(string|int|null $width = null, string|int|null $height = null): ClosureThe pipe form of ->size().