The stat-first spelling of geom_brain(). Both build the same layer – a
StatBrain that aggregates and joins your data onto the atlas geometry,
drawn by geom. Reach for stat_brain() when you want to pair StatBrain
with a different geom (e.g. a custom polygon geom); otherwise geom_brain()
is the friendlier entry point.
Usage
stat_brain(
mapping = aes(),
data = NULL,
atlas,
hemi = NULL,
view = NULL,
position = position_brain(),
context = TRUE,
context_fill = "grey",
fun = mean,
geom = GeomBrain,
show.legend = NA,
inherit.aes = TRUE,
...
)Arguments
- mapping
Set of aesthetic mappings created by
ggplot2::aes().- data
A data.frame containing variables to map. If
NULL, the atlas is plotted without user data. Add a facet withggplot2::facet_wrap()to draw one brain per group.- atlas
- hemi
Character vector of hemispheres to include (e.g.
"left","right"). Defaults to all hemispheres in the atlas.- view
Character vector of views to include, as recorded in the atlas data. For cortical atlases:
"lateral","medial". For subcortical/tract atlases: slice identifiers like"axial_2". Defaults to all views.- position
Brain-view layout: the result of a call to
position_brain(), a layout string (e.g."horizontal","vertical"), or a layout formula (e.g.hemi ~ view). Strings and formulas are passed toposition_brain(). Use"identity"to keep the atlas polygons' raw coordinates. Per-view zoom is set throughposition_brain()'szoom.- context
Keep the rest of the brain as a soft grey backdrop (
TRUE, the default), or show only the regions you're plotting (FALSE).The backdrop is drawn as a layer of its own, underneath the regions and outside any fill scale, so a mapped
fillnever reaches it and it claims no legend key. Set its colour withcontext_fill.- context_fill
Colour of the context backdrop. Defaults to
"grey". Only used whencontext = TRUE.- fun
Function used to combine multiple
datarows that map to the same atlas region, applied within each facet panel. Defaults tomean(). Any function reducing a vector to a single value works (e.g.median(),max()). It applies to numeric columns only; non-numeric ones take the first value of the group. Up to ggseg 2.2.1 duplicate rows overplotted, so the last one won —fun = dplyr::lastreproduces that.- geom
The geometric object used to render the atlas. Defaults to GeomBrain.
- show.legend
Logical. Should this layer be included in the legends?
- inherit.aes
Logical. If
FALSE, overrides the default aesthetics rather than combining with them.- ...
Additional arguments passed to
ggplot2::geom_polygon().

