Thanks.
So I have been able to create something similar. I am using numbers instead of dates, but the same issue is occurring - the order of the animation frame is ignoring my order and is in numerical order.
If anyone is able to replicate the date format I have, that may be useful too.
(sorry for not using reprex properly or for lousy formatting!)
#data#
mySample <- data.frame(pg = c("v1", "v2", "v3"),spi = c(0.3, 0.5, 0.7),cpi = c(0.4, 0.5, 0.8),bac = c(100, 1000, 250))
myDates<-data.frame(m=c(1,3,2))
df<-cbind(mySample ,myDates)
names(df)<-c("pg","spi","cpi","bac","m")
#script#
p <- df %>%
plot_ly(x = ~spi,
y = ~cpi,
color = ~pg,
frame = ~m)%>%
add_trace(mode = "markers",
hoverinfo = "text",
hovertext=~t,
type = 'scatter',
size = ~bac,
sizes = c(10, 40),
marker = list(
line = list(
color = ~pg,
width = 1
)))%>%
add_trace(mode = "text",
type = 'scatter',
hoverinfo = "none",
text = ~pg,
#textposition = "top right",
textfont = list(color = '#000000',size=14)
)%>%
layout( yaxis = list(showgrid = FALSE),
xaxis = list(showgrid = FALSE),
showlegend = FALSE,
plot_bgcolor='#ff0000',
shapes = list(
list(type = "rect",
fillcolor = "#ffc000", line = list(color = "#ffc000"),
x0 = 0.85, x1 = 1.15, xref = "x",
y0 = 0.85, y1 = 1.15, yref = "y",layer="below"),
list(type = "rect",
fillcolor = "008000", line = list(color = "008000"),
x0 = 0.95, x1 = 1.05, xref = "x",
y0 = 0.95, y1 = 1.05, yref = "y",layer="below"),
list(type = "line",
line = list(color = "black", dash = 'dash'),
x0 = 1, x1 = 1, xref = "x",
y0 = 0, y1 = 2, yref = "y"),
list(type = "line",
line = list(color = "black", dash = 'dash'),
x0 = 0, x1 = 2, xref = "x",
y0 = 1, y1 = 1, yref = "y")
))%>%
animation_slider(currentvalue = list(prefix = "Reporting Month: ")) %>%
animation_opts(750)
p