Plotly seems to have a bug, otherwise I can't understand the issue. Until it is solved, I would need a workaround.
Does anyone understand why this with four unique years is working
library(sf)
library(plotly)
library(ggplot2)
library(dplyr)
dat = data.frame(cla = factor(rep(LETTERS[1:2],10)), year = rep(c(2018:2022),4),x=runif(20, 1, 99),y = runif(20, 1, 99))
dat_sf = st_as_sf(dat, coords = c("x","y"))
gg = dat_sf %>%
ggplot(aes(color=cla, frame = year)) +
geom_sf(size=3)
ggplotly(gg)
and this throws with five years an error
dat = data.frame(cla = factor(rep(LETTERS[1:2],10)), year = rep(c(2018:2021),5),x=runif(20, 1, 99),y = runif(20, 1, 99))
dat_sf = st_as_sf(dat, coords = c("x","y"))
gg = dat_sf %>%
ggplot(aes(color=cla, frame = year)) +
geom_sf(size=3)
ggplotly(gg)