Adding second slider with geom_sf and ggplotly

Hello,
I am trying to add second slider to my graph using geom_sf and ggplotly. it’s working with using frame1 in geom_sf but I couldn’t figure out how to add second frame ( frame2 ) here. Here is my code;

frame1 <- eth_pp_sf$offset
frame2 <- eth_pp_sf$offset_1
colorhwam <- eth_pp_sf$HWAM


p <- ggplot()+
  geom_sf(data = eth, size=0.25, alpha=0.5, fill=NA) +
  geom_sf(data = eth_pp_sf, aes( frame=frame1, color = colorhwam), shape=15, size=0.8333333) +

  #scale_color_gradientn(colours = hex) 
  scale_color_gradientn(colours = rainbow(5) 
                        #breaks =c(45,50, 55, 60, 65, 70,75,
                         #         80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160),
                        #expand_scale(mult = c(3,3)))
  )
p  


d <- ggplotly(p) %>%
  animation_opts(frame=4000, transition = 500)%>%
  layout(title = 'title1',
         xaxis = list(title = 'LONGITUDE',
                      zeroline = TRUE,
                      range = c(30, 52)),
         yaxis = list(title = 'LATITUDE',
                      range = c(2,16)))%>%
         animation_slider(active=0,
                          currentvalue = list(prefix="prefix1: ", font = list(color="red"))
                        )
    
    
d

Thank you in advance!!

I doubt that you can do this with existing plotly commands. If you put the whole thing in shiny you can create two sliders and link them to the plotly animation. But you will have to manually do the animation, it's a bit fiddly. Here's an example.

Actually, it doesn't matter if I have to do the animation manually. How can I do this in R-shiny. I have never used it before.

Thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.