R6 class for a single panel of a ggbrain image
R6 class for a single panel of a ggbrain image
a ggbrain_panel R6 class with fields related to a panel on the ggbrain plot
ggThe ggplot object that contains the panel
new()create a new ggbrain_panel object
ggbrain_panel$new(
layers = NULL,
title = NULL,
bg_color = NULL,
text_color = NULL,
border_color = NULL,
border_size = NULL,
xlab = NULL,
ylab = NULL,
theme_custom = NULL,
annotations = NULL,
region_labels = NULL
)layersa list of ggbrain_layer objects to form the panel
titlea title for the panel added to the ggplot object using ggtitle()
bg_colorthe color used for the background of the plot. Default: 'gray10' (nearly black)
text_colorthe color used for text displayed on the plot. Default: 'white'.
border_colorthe color used for drawing a border around on the plot. Default: 'gray50' (though borders are not drawn by default).
border_sizethe size of the border line drawn around the panel. Default: NULL. If this value is
greater than zero, a border of this size and with color border_color will be drawn around the panel
xlabThe label to place on x axis. Default is NULL.
ylabThe label to place on y axis. Default is NULL.
theme_customAny custom theme() settings to be added to the plot
annotationsa data.frame containing all annotations to be added to this plot. Each row is cleaned up and passed to ggplot2::annotate()
region_labelsa list of ggbrain_label objects with data for plotting region labels on this panel
reset_limits()Reset the scale limits for the specified layers
ggbrain_panel$reset_limits(layer_names)layer_namesnot implemented yet
use_global_limitsNot implemented at present
add_to_gg()add one or more custom ggplot settings to the panel
ggbrain_panel$add_to_gg(list_args)list_argsA list containing elements to add to the ggplot object
Note that passing in an expression such as theme_bw() + ggtitle("hello") will not work because it creates an object that cannot be added sequentially to the ggplot. As noted in ggplot2's documentation (https://ggplot2.tidyverse.org/reference/gg-add.html), to programmatically add elements to a ggplot, pass in a list where each element is added sequentially
add_layer()adds a ggplot_layer object to the panel
ggbrain_panel$add_layer(layer_obj)layer_obja ggbrain_layer object to add to the panel
remove_layers()removes one or more layers by name
ggbrain_panel$remove_layers(layer_names)layer_namesa character string of the layers to remove from the panel
get_data()returns the data for all layers in the object
ggbrain_panel$get_data()
get_layer_names()returns the names of the layers in this panel, ordered from bottom to top
ggbrain_panel$get_layer_names()
get_layers()returns a list of ggbrain_layer objects that comprise this panel
ggbrain_panel$get_layers()
set_layer_order()sets the order of layers from bottom to top based on the layer names provided
ggbrain_panel$set_layer_order(ordered_names = NULL)ordered_namesthe names of the layers in the desired order from bottom to top. All layer names must be provided, not just a subset
clone()The objects of this class are cloneable with this method.
ggbrain_panel$clone(deep = FALSE)deepWhether to make a deep clone.
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 slices().