Description
Use `theme()` to modify individual components of a theme, allowing
you to control the appearance of all non-data components of the plot.
`theme()` only affects a single plot: see [theme_update()] if
you want modify the active theme, to affect all subsequent plots.
Theme inheritance
Theme elements inherit properties from other theme elements.
For example, `axis.title.x` inherits from `axis.title`,
which in turn inherits from `text`. All text elements inherit
directly or indirectly from `text`; all lines inherit from
`line`, and all rectangular objects inherit from `rect`.
This means that you can modify the appearance of multiple elements by
setting a single high-level component.
Usage
theme(line, rect, text, title, aspect.ratio, axis.title, axis.title.x, axis.title.x.top, axis.title.y, axis.title.y.right, axis.text, axis.text.x, axis.text.x.top, axis.text.y, axis.text.y.right, axis.ticks, axis.ticks.x, axis.ticks.y, axis.ticks.length, axis.line, axis.line.x, axis.line.y, legend.background, legend.margin, legend.spacing, legend.spacing.x, legend.spacing.y, legend.key, legend.key.size, legend.key.height, legend.key.width, legend.text, legend.text.align, legend.title, legend.title.align, legend.position, legend.direction, legend.justification, legend.box, legend.box.just, legend.box.margin, legend.box.background, legend.box.spacing, panel.background, panel.border, panel.spacing, panel.spacing.x, panel.spacing.y, panel.grid, panel.grid.major, panel.grid.minor, panel.grid.major.x, panel.grid.major.y, panel.grid.minor.x, panel.grid.minor.y, panel.ontop, plot.background, plot.title, plot.subtitle, plot.caption, plot.margin, strip.background, strip.placement, strip.text, strip.text.x, strip.text.y, strip.switch.pad.grid, strip.switch.pad.wrap, tern.axis.arrow, tern.axis.arrow.T, tern.axis.arrow.L, tern.axis.arrow.R, tern.axis.arrow.text, tern.axis.arrow.text.T, tern.axis.arrow.text.L, tern.axis.arrow.text.R, tern.axis.arrow.start, tern.axis.arrow.finish, tern.axis.arrow.sep, tern.axis.arrow.show, tern.axis.clockwise, tern.axis.vshift, tern.axis.hshift, tern.axis.line.ontop, tern.axis.line, tern.axis.line.T, tern.axis.line.L, tern.axis.line.R, tern.axis.text, tern.axis.text.T, tern.axis.text.L, tern.axis.text.R, tern.axis.text.show, tern.axis.ticks, tern.axis.ticks.length.major, tern.axis.ticks.length.minor, tern.axis.ticks.major, tern.axis.ticks.major.T, tern.axis.ticks.major.L, tern.axis.ticks.major.R, tern.axis.ticks.minor, tern.axis.ticks.minor.T, tern.axis.ticks.minor.L, tern.axis.ticks.minor.R, tern.axis.ticks.outside, tern.axis.ticks.primary.show, tern.axis.ticks.secondary.show, tern.axis.title, tern.axis.title.T, tern.axis.title.L, tern.axis.title.R, tern.axis.title.show, tern.panel.background, tern.panel.expand, tern.panel.grid.major, tern.panel.grid.major.T, tern.panel.grid.major.L, tern.panel.grid.major.R, tern.panel.grid.major.show, tern.panel.grid.minor, tern.panel.grid.minor.T, tern.panel.grid.minor.L, tern.panel.grid.minor.R, tern.panel.grid.minor.show, tern.panel.grid.ontop, tern.panel.mask.show, tern.panel.rotate, tern.plot.background, tern.plot.latex, ..., complete = FALSE, validate = TRUE)
Arguments
- line
- all line elements (
element_line
)
- rect
- all rectangular elements (
element_rect
)
- text
- all text elements (
element_text
)
- title
- all title elements: plot, axes, legends (
element_text
;
inherits from text
)
- aspect.ratio
- aspect ratio of the panel
- axis.title
- label of axes (
element_text
; inherits from
text
)
- axis.title.x
- x axis label (
element_text
; inherits from
axis.title
)
- axis.title.x.top
- x axis label on top axis (
element_text
;
inherits from axis.title.x
)
- axis.title.y
- y axis label (
element_text
; inherits from
axis.title
)
- axis.title.y.right
- y axis label on right axis (
element_text
;
inherits from axis.title.y
)
- axis.text
- tick labels along axes (
element_text
; inherits from
text
)
- axis.text.x
- x axis tick labels (
element_text
; inherits from
axis.text
)
- axis.text.x.top
- x axis tick labels on top axis (
element_text
;
inherits from axis.text.x
)
- axis.text.y
- y axis tick labels (
element_text
; inherits from
axis.text
)
- axis.text.y.right
- y axis tick labels on right axis
(
element_text
; inherits from axis.text.y
)
- axis.ticks
- tick marks along axes (
element_line
; inherits from
line
)
- axis.ticks.x
- x axis tick marks (
element_line
; inherits from
axis.ticks
)
- axis.ticks.y
- y axis tick marks (
element_line
; inherits from
axis.ticks
)
- axis.ticks.length
- length of tick marks (
unit
)
- axis.line
- lines along axes (
element_line
; inherits from
line
)
- axis.line.x
- line along x axis (
element_line
; inherits from
axis.line
)
- axis.line.y
- line along y axis (
element_line
; inherits from
axis.line
)
- legend.background
- background of legend (
element_rect
; inherits
from rect
)
- legend.margin
- the margin around each legend (
margin
)
- legend.spacing
- the spacing between legends (
unit
)
- legend.spacing.x
- the horizontal spacing between legends (
unit
);
inherits from legend.spacing
- legend.spacing.y
- the horizontal spacing between legends (
unit
);
inherits from legend.spacing
- legend.key
- background underneath legend keys (
element_rect
;
inherits from rect
)
- legend.key.size
- size of legend keys (
unit
)
- legend.key.height
- key background height (
unit
; inherits from
legend.key.size
)
- legend.key.width
- key background width (
unit
; inherits from
legend.key.size
)
- legend.text
- legend item labels (
element_text
; inherits from
text
)
- legend.text.align
- alignment of legend labels (number from 0 (left) to
1 (right))
- legend.title
- title of legend (
element_text
; inherits from
title
)
- legend.title.align
- alignment of legend title (number from 0 (left) to
1 (right))
- legend.position
- the position of legends ("none", "left", "right",
"bottom", "top", or two-element numeric vector)
- legend.direction
- layout of items in legends ("horizontal" or
"vertical")
- legend.justification
- anchor point for positioning legend inside plot
("center" or two-element numeric vector) or the justification according to
the plot area when positioned outside the plot
- legend.box
- arrangement of multiple legends ("horizontal" or
"vertical")
- legend.box.just
- justification of each legend within the overall
bounding box, when there are multiple legends ("top", "bottom", "left", or
"right")
- legend.box.margin
- margins around the full legend area, as specified
using
margin
- legend.box.background
- background of legend area (
element_rect
;
inherits from rect
)
- legend.box.spacing
- The spacing between the plotting area and the
legend box (
unit
)
- panel.background
- background of plotting area, drawn underneath plot
(
element_rect
; inherits from rect
)
- panel.border
- border around plotting area, drawn on top of plot so that
it covers tick marks and grid lines. This should be used with
fill=NA
(element_rect
; inherits from rect
)
- panel.spacing
- spacing between facet panels (
unit
)
- panel.spacing.x
- horizontal spacing between facet panels (
unit
;
inherits from panel.spacing
)
- panel.spacing.y
- vertical spacing between facet panels (
unit
;
inherits from panel.spacing
)
- panel.grid
- grid lines (
element_line
; inherits from line
)
- panel.grid.major
- major grid lines (
element_line
; inherits from
panel.grid
)
- panel.grid.minor
- minor grid lines (
element_line
; inherits from
panel.grid
)
- panel.grid.major.x
- vertical major grid lines (
element_line
;
inherits from panel.grid.major
)
- panel.grid.major.y
- horizontal major grid lines (
element_line
;
inherits from panel.grid.major
)
- panel.grid.minor.x
- vertical minor grid lines (
element_line
;
inherits from panel.grid.minor
)
- panel.grid.minor.y
- horizontal minor grid lines (
element_line
;
inherits from panel.grid.minor
)
- panel.ontop
- option to place the panel (background, gridlines) over
the data layers. Usually used with a transparent or blank
panel.background
. (logical
)
- plot.background
- background of the entire plot (
element_rect
;
inherits from rect
)
- plot.title
- plot title (text appearance) (
element_text
; inherits
from title
) left-aligned by default
- plot.subtitle
- plot subtitle (text appearance) (
element_text
;
inherits from title
) left-aligned by default
- plot.caption
- caption below the plot (text appearance)
(
element_text
; inherits from title
) right-aligned by default
- plot.margin
- margin around entire plot (
unit
with the sizes of
the top, right, bottom, and left margins)
- strip.background
- background of facet labels (
element_rect
;
inherits from rect
)
- strip.placement
- placement of strip with respect to axes,
either "inside" or "outside". Only important when axes and strips are
on the same side of the plot.
- strip.text
- facet labels (
element_text
; inherits from
text
)
- strip.text.x
- facet labels along horizontal direction
(
element_text
; inherits from strip.text
)
- strip.text.y
- facet labels along vertical direction
(
element_text
; inherits from strip.text
)
- strip.switch.pad.grid
- space between strips and axes when strips are
switched (
unit
)
- strip.switch.pad.wrap
- space between strips and axes when strips are
switched (
unit
)
- tern.axis.arrow
- Base Arrow Line (`element_line`; inherits from `axis.line`)
- tern.axis.arrow.T
- Arrow Line for TOP Axis (`element_line`; inherits from `tern.axis.arrow`)
- tern.axis.arrow.L
- Arrow Line for LHS Axis (`element_line`; inherits from `tern.axis.arrow`)
- tern.axis.arrow.R
- Arrow Line for RHS Axis (`element_line`; inherits from `tern.axis.arrow`)
- tern.axis.arrow.text
- Base Arrow Label (`element_text`; inherits from `tern.axis.text`)
- tern.axis.arrow.text.T
- Arrow Label on TOP Axis (`element_text`; inherits from `tern.axis.arrow.text`)
- tern.axis.arrow.text.L
- Arrow Label on LHS Axis (`element_text`; inherits from `tern.axis.arrow.text`)
- tern.axis.arrow.text.R
- Arrow Label on RHS Axis (`element_text`; inherits from `tern.axis.arrow.text`)
- tern.axis.arrow.start
- Proportion of Axis when Arrow Starts (`numeric`)
- tern.axis.arrow.finish
- Proportion of Axis when Arrow Finishes (`numeric`)
- tern.axis.arrow.sep
- Arrows Seperation from Axis (`numeric`)
- tern.axis.arrow.show
- Arrows Show or Hide (`logical`)
- tern.axis.clockwise
- Clockwise or Anticlockwise Precession (`logical`)
- tern.axis.vshift
- Amount to nudge the plot vertically (`numeric`)
- tern.axis.hshift
- Amount to nudge the plot horizontally (`numeric`)
- tern.axis.line.ontop
- Bring Axis Borders on Top of Everything (Depreciated) (`logical`)
- tern.axis.line
- Base Line (`element_line`; inherits from `axis.line`)
- tern.axis.line.T
- Line for TOP Axis (`element_line`; inherits from `tern.axis.line`)
- tern.axis.line.L
- Line for LHS Axis (`element_line`; inherits from `tern.axis.line`)
- tern.axis.line.R
- Line for RHS Axis (`element_line`; inherits from `tern.axis.line`)
- tern.axis.text
- Base Text (`element_text`; inherits from `axis.text`)
- tern.axis.text.T
- Text for TOP Axis (`element_text`; inherits from `tern.axis.text`)
- tern.axis.text.L
- Text for LHS Axis (`element_text`; inherits from `tern.axis.text`)
- tern.axis.text.R
- Text for RHS Axis (`element_text`; inherits from `tern.axis.text`)
- tern.axis.text.show
- Axis Labels Show or Hide (`logical`)
- tern.axis.ticks
- Base Ticks (`element_line`; inherits from `axis.ticks`)
- tern.axis.ticks.length.major
- Ticks Major Ticklength (`unit`)
- tern.axis.ticks.length.minor
- Ticks Minor Ticklength (`unit`)
- tern.axis.ticks.major
- Base Major Ticks (`element_line`; inherits from `tern.axis.ticks`)
- tern.axis.ticks.major.T
- Base Major Ticks for TOP Axis (`element_line`; inherits from `tern.axis.ticks.major`)
- tern.axis.ticks.major.L
- Base Major Ticks for LHS Axis (`element_line`; inherits from `tern.axis.ticks.major`)
- tern.axis.ticks.major.R
- Base Major Ticks for RHS Axis (`element_line`; inherits from `tern.axis.ticks.major`)
- tern.axis.ticks.minor
- Base Minor Ticks (`element_line`; inherits from `tern.axis.ticks`)
- tern.axis.ticks.minor.T
- Base Minor Ticks for TOP Axis (`element_line`; inherits from `tern.axis.ticks.minor`)
- tern.axis.ticks.minor.L
- Base Minor Ticks for LHS Axis (`element_line`; inherits from `tern.axis.ticks.minor`)
- tern.axis.ticks.minor.R
- Base Minor Ticks for RHS Axis (`element_line`; inherits from `tern.axis.ticks.minor`)
- tern.axis.ticks.outside
- Ticks Outside or Inside (`logical`)
- tern.axis.ticks.primary.show
- Ticks Show Primary (`logical`)
- tern.axis.ticks.secondary.show
- Ticks Show Secondary (`logical`)
- tern.axis.title
- Base Apex Title (`element_text`; inherits from `axis.title`)
- tern.axis.title.T
- Apex Title for TOP Axis (`element_text`; inherits from `tern.axis.title`)
- tern.axis.title.L
- Apex Title for LHS Axis (`element_text`; inherits from `tern.axis.title`)
- tern.axis.title.R
- Apex Title for RHS Axis (`element_text`; inherits from `tern.axis.title`)
- tern.axis.title.show
- Apex Titles Show or Hide (`logical`)
- tern.panel.background
- Background of Ternary Plot Area** (`element_rect`; inherits from `panel.background`)
- tern.panel.expand
- The amount to expand the ternary plotting panel, in ratio to npc units (`numeric`)
- tern.panel.grid.major
- Base Major Gridline (`element_line`; inherits from `panel.grid.major`)
- tern.panel.grid.major.T
- Major Gridline for TOP Axis (`element_line`; inherits from `tern.panel.grid.major`)
- tern.panel.grid.major.L
- Major Gridline for LHS Axis (`element_line`; inherits from `tern.panel.grid.major`)
- tern.panel.grid.major.R
- Major Gridline for RHS Axis (`element_line`; inherits from `tern.panel.grid.major`)
- tern.panel.grid.major.show
- Show or Hide Major Gridline (`logical`)
- tern.panel.grid.minor
- Base Minor Gridline (`element_line`; inherits from `panel.grid.minor`)
- tern.panel.grid.minor.T
- Minor Gridline for TOP Axis (`element_line`; inherits from `tern.panel.grid.minor`)
- tern.panel.grid.minor.L
- Minor Gridline for LHS Axis (`element_line`; inherits from `tern.panel.grid.minor`)
- tern.panel.grid.minor.R
- Minor Gridline for RHS Axis (`element_line`; inherits from `tern.panel.grid.minor`)
- tern.panel.grid.minor.show
- Show or Hide Minor Gridline (`logical`)
- tern.panel.grid.ontop
- Bring grids, axis and axis labels on top of everything else (`logical`)
- tern.panel.mask.show
- Show or Hide the Clipping Mask (`logical`)
- tern.panel.rotate
- The amount to rotate the ternary diagram in degrees (`numeric`)
- tern.plot.background
- Background of Ternary Clipping Area** (`element_rect`; inherits from `plot.background`)
- tern.plot.latex
- Whether to parse characters as latex commands (`logical`)
- ...
- additional element specifications not part of base ggplot2. If
supplied
validate
needs to be set to FALSE
.
- complete
- set this to TRUE if this is a complete theme, such as
the one returned
by theme_grey()
. Complete themes behave
differently when added to a ggplot object. Also, when setting
complete = TRUE
all elements will be set to inherit from blank
elements.
- validate
TRUE
to run validate_element, FALSE
to bypass checks.