Black Lives Matter. Please consider donating to Black Girls Code today.

Plotting a geom_point with plotly not displaying all variables in the legend

Hello, I seem to be having some trouble getting the legend in plotly to show all the levels in my plot. The points are displaying as different colours but the colours are not showing in the legend for all three levels of TIME.OF.DAY. I also do not understand why the size of the points are not scaled to their numeric value.

Is this something to do with the animation by chance?

#create some data
V1<-c(-9376.380, -9277.487, -9230.091, -9206.468, -9105.490, -9114.848 ,-8948.438, -8926.035, -8836.179, -9435.464, -9435.327, -9435.103, -9201.675 ,-9114.730, -8964.441 ,-9116.536 ,-9099.325)
V2<-c( 5660210, 5660399, 5659853 ,5660251 ,5660160 ,5660463, 5660428, 5660328 ,5660437 ,5659898, 5659899 ,5659901, 5660251, 5660162 ,5660436, 5660162, 5660491)
levels<-c(8 ,8 ,8 ,8,8,8,8, 8,8, 6,7, 8, 15, 20, 15 ,20,30)
TIME.OF.DAY<-c(“EVENING” , “EVENING” , “EVENING” , “EVENING” , “EVENING” , “EVENING” , “EVENING”, “EVENING” , “EVENING” , “EVENING” , “EVENING” , “EVENING” , “AFTERNOON” ,“AFTERNOON”, “AFTERNOON” ,“AFTERNOON”, “MORNING” )
TIME.OF.YEAR<-c( “SUMMER” ,“SUMMER”, “SUMMER”, “SUMMER” ,“SUMMER”, “SUMMER”, “SUMMER”, “SUMMER”, “SUMMER”, “FALL” , “FALL” ,“FALL” , “EXAMS” , “EXAMS” , “EXAMS” , “EXAMS” , “SUMMER”)
test_polygons<-as.data.frame(cbind(V1,V2,levels,TIME.OF.DAY,TIME.OF.YEAR))

#plot in ggplot
p<-ggplot()+
geom_point(data=test_polygons, aes(x=V1, y=V2, color=TIME.OF.DAY, size=levels, text=levels, frame=TIME.OF.YEAR))+
theme_void()

#plot with ggplotly
test_plotly <- ggplotly(p,tooltip=“text”) %>%
animation_button(
x = 1, xanchor = “right”, y = 0, yanchor = “bottom”
) %>%
animation_opts(
1000, easing = “elastic”, redraw = FALSE
)

#dispaly plot
test_plotly