Last active
October 23, 2020 05:03
-
-
Save yjunechoe/b39e92889768b26faaec3e0103d4af10 to your computer and use it in GitHub Desktop.
gganimate gif for visual-world eye-tracking data from de Carvalho et al. (2017)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_csv("https://yjunechoe.netlify.app/data/CarvalhoEtAl_2017.csv", col_types = cols(reveal_time = col_integer())) %>% | |
ggplot(aes(Time, Proportion)) + | |
geom_ribbon( | |
aes(ymin = YMin, ymax = YMax, group = Condition), | |
color = "grey70", | |
fill = "grey80", | |
alpha = .3 | |
) + | |
geom_point( | |
aes(color = Condition, group = Condition) | |
) + | |
geom_line( | |
aes(color = Condition, group = Condition), | |
size = 1 | |
) + | |
geom_segment( | |
aes(xend = 6500, yend = Proportion, group = Condition), | |
linetype = 2, | |
color = 'grey' | |
) + | |
geom_text( | |
aes(x = 6750, label = paste(Condition, "Accent"), color = Condition, group = Condition), | |
hjust = 0, size = 4, family = "Montserrat") | |
+ | |
geom_text( | |
aes(x = 4100, y = 0.85, label = "Disambiguating Word Presented"), | |
data = tibble(reveal_time = 280L), | |
family = "Adelle", size = 3 | |
) + | |
geom_segment( | |
aes(x = 4100, xend = 4100, y = 0, yend = 0.8), | |
linetype = 2, size = .6, color = "red", | |
data = tibble(reveal_time = 280L) | |
) + | |
scale_y_continuous(limits = c(0, 1)) + | |
scale_x_continuous(labels = function(x) {paste0(x, "ms")}) + | |
coord_cartesian(clip = 'off', expand = FALSE, xlim = c(-1550, 6500)) + | |
palettetown::scale_color_poke(pokemon = "Squirtle", spread = 2) + | |
ggthemes::theme_clean(base_family = "Roboto") + | |
labs( | |
y = NULL, | |
title = "Proportion of looks towards NOUN picture", | |
x = "Time from onset of ambiguous word", | |
caption = "Source: de Carvalho et al. (2017)" | |
) + | |
theme( | |
plot.margin = margin(.5, 4, .4, 1, "cm"), | |
legend.position = 0, | |
plot.background = element_rect(color = "#f9f9f9"), | |
plot.title = element_text(family = "Roboto Slab", margin = margin(b = .5, unit = "cm")), | |
axis.title.x = element_text(margin = margin(t = .2, unit = "cm")), | |
plot.caption = element_text(family = "IBM Plex Mono", size = 7, margin = margin(t = .3, unit = "cm")), | |
plot.caption.position = "plot" | |
) + | |
transition_reveal(reveal_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment