Learn R Programming

ggbrain (version 0.9.0)

ggbrain_plot: An R6 class for constructing a ggbrain plot from a ggbrain_slices object

Description

An R6 class for constructing a ggbrain plot from a ggbrain_slices object

An R6 class for constructing a ggbrain plot from a ggbrain_slices object

Arguments

Value

a ggbrain_plot R6 class containing fields related to a ggbrain plot object

Active bindings

slices

a ggbrain_slices object containing all slice data for this plot

layers

a list of ggbrain_layer objects for this plot. Note that in assignment, the input can be a list of ggbrain_layer objects, or a list of lists where each inner element specifies the settings for that layer. Example: list(list(name='hello', fill_scale=scale_fill_distiller())

annotations

a list of annotations to be added to this plot

region_labels

a list of region_labels to be added to this plot

panel_settings

a list of panel settings (aesthetics) to be added to this plot

title

overall plot title, added to composite plot by patchwork::plot_annotation()

bg_color

background color of plot

text_color

the color of text use across panels (can be overridden by panel settings)

base_size

the base size of text used in ggplot theming

Methods


Method new()

instantiate a new instance of a ggbrain_plot object

Usage

ggbrain_plot$new(
  title = NULL,
  bg_color = NULL,
  text_color = NULL,
  base_size = NULL,
  slice_data = NULL
)

Arguments

title

overall plot title

bg_color

background color of plot

text_color

text color of plot

base_size

base size of text used in ggplot theming

slice_data

a ggbrain_slices object generated by ggbrain_images$get_slices()


Method add_layers()

adds one or more ggbrain_layer objects to this plot

Usage

ggbrain_plot$add_layers(layers = NULL)

Arguments

layers

a list of ggbrain_layer objects (can also be a list that just specifies names, definitions, etc.)


Method reset_layers()

removes all existing layers from this ggbrain_plot object

Usage

ggbrain_plot$reset_layers()


Method generate_plot()

generate the plot

Usage

ggbrain_plot$generate_plot(layers = NULL, slice_indices = NULL)

Arguments

layers

a list of layers to be displayed on each panel, the order of which yields the bottom-to-to drawing order within ggplot2. Each element of layers should be a list that follows the approximate structure of the ggbrain_layer class, minimally including the layer name, which is used to lookup data of images or contrasts within the slice_data object. If NULL, all layers in the slices object will be plotted. If only a character string is passed, then those layers will be plotted with default scales.

slice_indices

An optional subset of slice indices to display from the stored slice data

Details

In addition to name, the elements of a layer can include fill_scale a ggplot2 scale object for coloring the layer. Should be a scale_fill_* object. limits the numeric limits to use for the color scale of this layer breaks the scale breaks to use for the color scale of this layer show_legend if FALSE, the color scale will not appear in the legend


Method plot()

return a plot of all panels as a patchwork object

Usage

ggbrain_plot$plot(guides = "collect", ...)

Arguments

guides

Passes through to patchwork::plot_layout to control how legends are combined across plots. The default is "collect", which collects legends within a given nesting level (removes duplicates).

...

additional arguments. Not used currently


Method clone()

The objects of this class are cloneable with this method.

Usage

ggbrain_plot$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Note that this class is exported only for power users and rarely needs to be called directly in typical use of the package. Instead, look at ggbrain().