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()
.
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
layers
a list of ggbrain_layer objects to form the panel
title
a title for the panel added to the ggplot object using ggtitle()
bg_color
the color used for the background of the plot. Default: 'gray10' (nearly black)
text_color
the color used for text displayed on the plot. Default: 'white'.
border_color
the color used for drawing a border around on the plot. Default: 'gray50' (though borders are not drawn by default).
border_size
the 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 panelxlab
The label to place on x axis. Default is NULL.
ylab
The label to place on y axis. Default is NULL.
theme_custom
Any custom theme() settings to be added to the plot
annotations
a data.frame containing all annotations to be added to this plot. Each row is cleaned up and passed to ggplot2::annotate()
region_labels
a list of ggbrain_label objects with data for plotting region labels on this panel
Method plot()
plot the panel
Method add_to_gg()
add one or more custom ggplot settings to the panel
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 set_layer_order()
sets the order of layers from bottom to top based on the layer names provided