ggplot.eeg_lst: Create an ERP plot

ggplot.eeg_lstR Documentation

Create an ERP plot

Description

ggplot initializes a ggplot object which takes an eeg_lst object as its input data. Layers can then be added in the same way as for a ggplot2::ggplot object.

Usage

## S3 method for class 'eeg_lst'
ggplot(data = NULL, mapping = ggplot2::aes(), ..., .max_sample = 64000)

Arguments

data

An eeg_lst object.

mapping

Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot.

...

Other arguments passed on to methods. Not currently used.

.max_sample

Downsample to approximately 6400 samples by default.

Details

If necessary, t will first downsample the eeg_lst object so that there is a maximum of 6400 samples. The eeg_lst object is then converted to a long-format tibble via as_tibble. In this tibble, the .key variable is the channel/component name and .value its respective amplitude. The sample number (.sample in the eeg_lst object) is automatically converted to milliseconds to create the variable .time. By default, time is plotted on the x-axis and amplitude on the y-axis.

To add additional components to the plot such as titles and annotations, simply use the + symbol and add layers exactly as you would for ggplot2::ggplot.

Value

A ggplot object

See Also

Other plotting functions: annotate_electrodes(), annotate_events(), annotate_head(), eeg_downsample(), plot.eeg_lst(), plot_components(), plot_in_layout(), plot_topo(), theme_eeguana()

Examples

library(ggplot2)
library(dplyr)
# Plot grand averages for selected channels
data_faces_ERPs %>%
  # select the desired electrodes
  select(O1, O2, P7, P8) %>%
  ggplot(aes(x = .time, y = .key)) +
  # add a grand average wave
  stat_summary(
    fun.y = "mean", geom = "line", alpha = 1, linewidth = 1.5,
    aes(color = condition)
  ) +
  # facet by channel
  facet_wrap(~.key) +
  theme(legend.position = "bottom")
  

bnicenboim/eeguana documentation built on March 16, 2024, 7:21 a.m.