theme_cond: Change theme settings conditional on the type of plot

theme_condR Documentation

Change theme settings conditional on the type of plot

Description

Method to change theme settings conditional on the type of plot such as geom, facet etc.

Usage

## S3 method for class 'conditional_theme'
ggplot_add(object, plot, object_name)

Arguments

object

An object (theme) to add to the plot.

plot

The ggplot object to add object to as an list component.

object_name

The name of the object to add.

Details

The original idea was to use: plot$theme <- ggplot2:::add_theme(plot$theme, object, "object") for this purpose but ggplot2:::add_theme() is an internal ggplot2 function and is not exported.

Instead, the current theme in object consist of theme_nish_* settings. These theme properties are further modified based on the type of plot requested in the ggplot2 call, i.e. based on the geom, facet etc. outside the actual theme_nish_*() call, by this method.

plot$theme may initially (as input to this method) be an empty list if no theme() calls have been performed or set by the user in the working environment. The argument object always replaces an existing theme in plot$theme.

Value

A ggplot object.

Note

Conditional theme settings does not work with ggplot2::theme_set(). Explicit theme_nish_*() call is required by the user to enable conditional theme settings.


rrunner/nish documentation built on Aug. 9, 2022, 6:53 p.m.