ggplot.eeg_lst | R Documentation |
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.
## S3 method for class 'eeg_lst'
ggplot(data = NULL, mapping = ggplot2::aes(), ..., .max_sample = 64000)
data |
An |
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. |
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.
A ggplot object
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.