I did a basic ggplot analysis in R on a dataset of gaze data. The plot shows how the gaze points are distributed in a coordinate system:
I now want to add a simple slider that lets the points appear or dissappear in time. ifigured out that plotly package should be able to do this. Can you tell me what the code could be that I have to add in order to achieve my goal?
That is my current code:
ggplot(participant_208930511,aes(x = x_mav, y = y_mav, color = cut(time_proxy, breaks = c(1,50,350,405), labels = c("First period","Middle period","Last period")))) + scale_fill_distiller(palette=8, direction=1) + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) + theme(legend.position='n_one') + geom_point(size=1) + guides(color=guide_legend(title="Time category")) + participant_208930511 <- participant_208930511 %>% animation_slider(currentvalue = list(prefix = "time_sec", font = list(color="red")))
And this is what my dataset looks like. Time data is provided under "time_sec" or "time_proxy".
participant question time time_sec time_proxy x x_mav y y_mav
<dbl> <dbl> <dbl> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl>
1 208930511 7 1.54e12 2018-12-16 13:18:36 1 0 0 1397 1397
2 208930511 7 1.54e12 2018-12-16 13:18:36 2 234 234 1829 1829
3 208930511 7 1.54e12 2018-12-16 13:18:36 3 344 344 1598 1598
4 208930511 7 1.54e12 2018-12-16 13:18:37 4 -459 -459 1763 1763
5 208930511 7 1.54e12 2018-12-16 13:18:37 5 -629 -629 1560 1560
6 208930511 7 1.54e12 2018-12-16 13:18:37 6 284 284 1061 1061
Thank you in advance!!