If you run this code in R, it creates 12 plots and saves them in your current working directory. The plots illustrate a sequence of adjacent and nonadjacent dependencies. The names of the plots are in the right order (plot_1, plot_2,...).
Check it out first. Run the code, look at the plots and see if you can make sense of it; if not ask me.
Also I can explain the code more in detail if you're interested.
If there is anything you want to look different (size, text, etc), let me know and I can show you how to change it.
# Setup environment
library(tidyverse)
theme_set(theme_bw() +
theme(panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()))
# Location pairs
x <- c(-0.28496, -0.08992, -0.42000, -0.22496, -0.03000, 0.16504,
-0.16504, 0.03000, 0.22504, 0.42000, 0.09000, 0.28504)
y <- c(-0.20792, -0.38976, 0.23384, 0.05192, -0.13000, -0.31176,
0.31176, 0.12992, -0.05200, -0.23384, 0.38976, 0.20784)
# Grid of grey dots
grid <- tibble(x, y, id = 1:length(y))
# Create basis plot with only grey dots
plot <- ggplot(grid, aes(x = x, y = y)) +
geom_point(size = 10, colour = "grey") +
scale_x_continuous(limits = c(-.5,.5)) +
scale_y_continuous(limits = c(-.5,.5))
# Determine locations of adjacent and nonadjacent depencies
data <- tibble(condition = rep(c("adjacent", "nonadjacent"), each = 6),
id = c(5, 10, 8, 5, 10, 2,
5, 3, 10, 5, 12, 10),
type = c("x1", "x2", "random", "x1", "x2", "random",
"x1", "random", "x2", "x1", "random", "x2")) %>%
mutate(idx = 1:n())
# Iterate over data source, add green dots accordingly and save plot
# in current working directory
for(i in pull(data, idx)){
dot_id <- filter(data, idx == i) %>% pull(id)
locs <- filter(grid, id == dot_id)
x_id <- pull(locs, x)
y_id <- pull(locs, y)
title <- slice(data, i) %>%
transmute(text = str_c(condition, ": ", type)) %>%
pull(text)
plot_dot <- plot +
geom_point(aes(x = x_id,
y = y_id),
size = 10,
colour = "chartreuse3") +
labs(title = title)
filename <- str_c("plot_", i, ".png")
ggsave(filename = filename,
plot = plot_dot,
width = 6,
height = 5)
}
If you run this code in R, it creates 12 plots and saves them in your current working directory. The plots illustrate a sequence of adjacent and nonadjacent dependencies. The names of the plots are in the right order (plot_1, plot_2,...).
Check it out first. Run the code, look at the plots and see if you can make sense of it; if not ask me.
Also I can explain the code more in detail if you're interested.
If there is anything you want to look different (size, text, etc), let me know and I can show you how to change it.