| ggbrain_panel {ggbrain} | R Documentation |
R6 class for a single panel of a ggbrain image
Description
R6 class for a single panel of a ggbrain image
R6 class for a single panel of a ggbrain image
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 slices().
Value
a ggbrain_panel R6 class with fields related to a panel on the ggbrain plot
Public fields
ggThe ggplot object that contains the panel
Methods
Public methods
Method new()
create a new ggbrain_panel object
Usage
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 )
Arguments
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_colorwill be drawn around the panelxlabThe 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
Method reset_limits()
Reset the scale limits for the specified layers
Usage
ggbrain_panel$reset_limits(layer_names)
Arguments
layer_namesnot implemented yet
Method plot()
plot the panel
Usage
ggbrain_panel$plot(use_global_limits = TRUE)
Arguments
use_global_limitsNot implemented at present
Method add_to_gg()
add one or more custom ggplot settings to the panel
Usage
ggbrain_panel$add_to_gg(list_args)
Arguments
list_argsA list containing elements to add to the ggplot object
Details
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
Method add_layer()
adds a ggplot_layer object to the panel
Usage
ggbrain_panel$add_layer(layer_obj)
Arguments
layer_obja ggbrain_layer object to add to the panel
Method remove_layers()
removes one or more layers by name
Usage
ggbrain_panel$remove_layers(layer_names)
Arguments
layer_namesa character string of the layers to remove from the panel
Method get_data()
returns the data for all layers in the object
Usage
ggbrain_panel$get_data()
Method get_layer_names()
returns the names of the layers in this panel, ordered from bottom to top
Usage
ggbrain_panel$get_layer_names()
Method get_layers()
returns a list of ggbrain_layer objects that comprise this panel
Usage
ggbrain_panel$get_layers()
Method set_layer_order()
sets the order of layers from bottom to top based on the layer names provided
Usage
ggbrain_panel$set_layer_order(ordered_names = NULL)
Arguments
ordered_namesthe names of the layers in the desired order from bottom to top. All layer names must be provided, not just a subset
Method clone()
The objects of this class are cloneable with this method.
Usage
ggbrain_panel$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.