I'm using ggplotly in a shinyApp. The application works fine with ggplotly for normal graphs. However, when I tried to add animation to the graph, the graph only showed movements of the points not the whole graph. The code is running without errors but not showing the main graph. I suspect the issue could be from frame
argument. Please note that if you add aes(frame=F)
to geom_point
in below code it will work but not in ggplotly inside shinyApp.
here is my MWE:
x<-structure(list(A = c(0L, 0L, 0L, 0L, 0L), B = c(5L, 6L, 15L,
17L, 2L), C = c(0L, 0L, 0L, 0L, 0L), D = c(0L, 0L, 0L, 0L, 0L
), E = structure(c(18316, 18317, 18318, 18319, 18320), class = "Date"),
F = c(5L, 11L, 26L, 43L, 45L)), row.names = c(NA, 5L), class = "data.frame")
gp<-ggplot(data = x,
aes(x = E, y = F, frame=F)) +
geom_line( color="red") +
geom_point(shape=21, color="red", fill="#69b3a2", size=4) +
theme(axis.text.x = element_text(color="#993333",
size=10,
angle=45,
hjust = 1),
axis.text.y = element_text(color="#993333",
size=10,
angle=45,
hjust = 1)
) +
scale_x_date(date_labels = "%b/%d" )
#+show(gp)
ggplotly(gp)
Any suggestions ?