0

I am trying to create an animation where an image has to move together with the dot that you can see in this image:

Graph

I have a dataset about Formula 1 and I want to show the image of the car instead of the dot in the image.

Here you have a summary of my dataset:

Summary

And the code of the graph:

prep = data[data$year == 2021,] %>% split(.$date) %>% accumulate(., ~bind_rows(.x,.y))%>%
  bind_rows(.id = "frame")

prep2 = data[data$year == 2021,] %>% split(.$date) %>%
  bind_rows(.id = "frame")

prep%>%
  plot_ly(x = ~name, y = ~points, color = ~factor(name)) %>%
  add_lines(frame =  ~as.Date(frame, format = '%Y-%m-%d'))%>%
  add_markers(data = prep2, frame =  ~as.Date(frame, format = '%Y-%m-%d'))%>%
layout(yaxis = list(title = 'Puntos'),showlegend = FALSE,xaxis = list(title = 'Fecha de la carrera',range = c(as.Date(min(data$date[data$year == 2021]), format="%d/%m/%Y"),as.Date(max(data$date[data$year == 2021]), format="%d/%m/%Y"))))%>%
animation_slider(currentvalue = list(prefix = "Carrera "))
Kat
  • 15,669
  • 3
  • 18
  • 51
Hugo Albert
  • 31
  • 1
  • 3
  • It looks like you're new to SO; welcome to the community! If you want great answers quickly, it's best to make your question reproducible. This includes sample data like the output from `dput()` or `reprex::reprex()` and any libraries you use. (Pictures of data are not useful.) Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat Dec 29 '22 at 15:25

0 Answers0