theme
Use theme()
to modify individual components of a theme, allowing you to control the appearance of all non-data components of the plot. See also the Plot Layout Diagrams section.
Most parameters in theme()
control styling of text, line, and rectangular elements.
All styling parameters accept:
String "blank" or result of
elementBlank()
to hide the elementAdditionally, based on element type:
Text elements: result of
elementText()
Rectangular elements: result of
elementRect()
Line elements: result of
elementLine()
Parameter naming follows a pattern:
Parameters controlling text elements end with "Text" or "Title" (e.g.,
axisText
,plotTitle
)Parameters controlling rectangular elements end with "Background" or "Rect" (e.g.,
panelBackground
)Parameters controlling line elements end with "Line", "Grid", "Ticks", or "Border" (e.g.,
axisLine
,panelGrid
)
Settings passed via more specific parameters override settings passed via less specific parameters. For example, parameter axisLineX
is more specific than parameter axisLine
.
Examples
Parameters
default="e" ("e", "pow", "pow_full"). Controls the appearance of numbers formatted with "e" or "g" types.
Value is either a string - style, or a list: listOf(style, lower_exp_bound, upper_exp_bound)
where style
can be:
"e"
: e-notation (e.g., 1e+6)"pow"
: superscript powers of 10 in shortened form (e.g., 10^6)"pow_full"
: superscript powers of 10 with coefficient (e.g., 1×10^6)
For "g"
type formatting, scientific notation is applied when the number's exponent is less than or equal to the lower_exp_bound
(-7 by default) or greater than or equal to the upper_exp_bound
(6 by default, but can be affected by precision
in format specifier).
See: Formatting
Style settings for all line elements.
Style settings for all rectangular elements.
Style settings for all text elements.
Style settings for all title elements: plot, axes, legends.
Style settings for all axis elements: lines, ticks, texts, titles.
Option to place axis (lines, tick-marks and labels) over the data layers.
Option to place X-axis (lines, tick-marks and labels) over the data layers.
Option to place Y-axis (lines, tick-marks and labels) over the data layers.
Style settings for axis titles.
Style settings for axis titles.
Style settings for axis titles.
Style settings for tick labels along axes.
Style settings for tick labels along axes.
Style settings for tick labels along axes.
Style settings for tick marks along axes.
Style settings for tick marks along axes.
Style settings for tick marks along axes.
Length of tick marks.
Length of tick marks.
Length of tick marks.
Spacing between the axis label text and its tick mark.
Spacing between the axis label text and its tick mark.
Spacing between the axis label text and its tick mark.
Style settings for lines along axes.
Style settings for lines along axes.
Style settings for lines along axes.
Style settings for background of legend.
Style settings for legend item labels.
Style settings for legend title.
Margin around each legend. The margin may be specified using a number or a list of numbers:
a single number or a list of one number - the same margin is applied to all four sides;
a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
a list of four numbers - the margins are applied to the top, right, bottom and left in that order. It is acceptable to use
null
for any side; in this case, the default side value for the legend margin side will be used.
Spacing between legends.
Spacing between legends in the horizontal direction.
Spacing between legends in the vertical direction.
Style settings for legend key background.
Size of legend keys.
Key background width.
Key background height.
Spacing between legend keys
Spacing between legend keys in the horizontal direction.
Spacing between legend keys in the vertical direction.
Spacing between plotting area and legend box.
Style settings for tick marks in colorbars.
Length of tick marks in colorbar.
Style settings for background of plotting area.
Style settings for border around plotting area.
Option to place border around plotting area over the data layers.
Style settings for grid lines.
Style settings for major grid lines.
Style settings for minor grid lines.
Style settings for major grid lines.
Style settings for minor grid lines.
Style settings for major grid lines.
Style settings for minor grid lines.
Option to place major grid lines and minor grid lines over the data layers.
Option to place X-axis major grid lines and minor grid lines over the data layers.
Option to place Y-axis major grid lines and minor grid lines over the data layers.
Inset for a panel. The inset behaves like a padding for coordPolar(transformBkgr = false)
otherwise it behaves like a margin around the panel. The inset may be specified using a number or a list of numbers:
a single number or a list of one number - the same inset is applied to all four sides;
a list of two numbers - the first inset applies to the top and bottom, the second - to the left and right;
a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
a list of four numbers - the insets are applied to the top, right, bottom and left in that order. It is acceptable to use
null
for any side; in this case, the default value for the panel inset side will be used.
Style settings for overall plot background.
Style settings for plot title.
Style settings for plot subtitle.
Style settings for plot caption.
Style settings for plot message (e.g. sampling messages). Set an elementBlank()
to show nothing. Set an elementText()
to show sampling messages (elementText()
options do not affect the message text).
Margin around entire plot. The margin may be specified using a number or a list of numbers:
a single number or a list of one number - the same margin is applied to all four sides;
a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
a list of four numbers - the margins are applied to the top, right, bottom and left in that order. It is acceptable to use
null
for any side; in this case, the default side value for the plot margin side will be used.
Inset for a plotting area, including the axes with their labels, but without titles. The inset may be specified using a number or a list of numbers:
a single number or a list of one number - the same inset is applied to all four sides;
a list of two numbers - the first inset applies to the top and bottom, the second - to the left and right;
a list of three numbers - the first inset applies to the top, the second - to the right and left, the third - to the bottom;
a list of four numbers - the insets are applied to the top, right, bottom and left in that order.
It is acceptable to use null
for any side; in this case, the default value for the plot inset side will be used.
default = "panel" ("panel", "plot"). Alignment of the plot title/subtitle. A value of "panel" means that title and subtitle are aligned to the plot panels. A value of "plot" means that title and subtitle are aligned to the entire plot (excluding margins).
default = "panel" ("panel", "plot"). Alignment of the plot caption. A value of "panel" means that caption is aligned to the plot panels. A value of "plot" means that caption is aligned to the entire plot (excluding margins).
Style settings for facet strip background.
Style settings for horizontal facet strip background.
Style settings for vertical facet strip background.
Style settings for facet labels.
Style settings for horizontal facet labels.
Style settings for vertical facet labels.
Style settings for axes tooltips.
Style settings for axes tooltips.
Style settings for axes tooltips.
Style settings for text in axes tooltips.
Style settings for text in axes tooltips.
Style settings for text in axes tooltips.
Style settings for general tooltip.
Style settings for text in general tooltip.
Style settings for tooltip title text.
Style settings for annotation text. Annotations are currently supported for pie and bar charts. Set elementText()
to specify annotation text parameters: font family and face, text size, text color (relevant for a pie chart - for those annotations that are outside the pie).
Color settings for geometries.
Constructors
Properties
Functions
Arrangement of multiple legends: horizontal or vertical.
Justification of each legend within the overall bounding box, when there are multiple legends.
Specifies the anchor point for positioning legend inside plot. Justification (0, 0) corresponds to the left, lower corner of the legend. Justification (1, 1) corresponds to the right, upper corner of the legend.
Specifies the legend position relative to the plot drawing area. Position (0, 0) corresponds to the left, lower corner of the plot. Position (1, 1) corresponds to the right, upper corner of the plot.