,
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.
An eeg_lst
object.
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.
Downsample to approximately 6400 samples by default.
A ggplot object
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.
Other plotting functions:
annotate_electrodes()
,
annotate_events()
,
annotate_head()
,
eeg_downsample()
,
plot.eeg_lst()
,
plot_components()
,
plot_in_layout()
,
plot_topo()
,
theme_eeguana()
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")
#> Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
#> ℹ Please use the `fun` argument instead.
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?