This tutorial shows one way to make plots depicting a simulated experiment.
# Load the verse'.
library(tidyverse)
# Load themes for plotting.
library(ggthemes)
# Import a csv.
df <- read_csv("three_vecs_a")
This first one attempts to show a small increase in all subjects who exercise relative to controls.
# Make plot p1
p1 <- ggplot(df, aes(x = wmone, y = wmtwo, linetype = group)) + # linetype splits 2 lines for the 2 groups
theme_tufte() + geom_smooth(method = "lm", fill = NA, colour = "black") +
geom_smooth(show.legend = F, method = "lm", alpha = .1, se = F, colour = "black") +
labs(
title = "Fig 1: Individual Differences",
x = "Working Memory at Session 1",
y = "Working Memory at Session 2",
linetype = "Group",
subtitle = "Length of lines and slopes depict a simulated sample.",
caption = "All subjects in the treatment group show a small increase in working memory after acute exercise."
) +
theme(
legend.text = element_text(size = rel(1.5)), # Boost the legend text font size
legend.title = element_text(size = rel(1.5)), # Boost the legend title font size
legend.key = element_rect(fill = "white") # Get rid of the gray background in the legend
)
# Show plot p1
p1
More on the way…