我正在使用plotly
为应该绘制在多边形前面的标记设置动画。但是,标记每隔一帧移动到多边形后面。我可以设置redraw = TRUE
,但是标记仍然闪烁。有没有办法阻止这种情况的发生?
一个可重现的示例,其中标记是固定的,但每帧都会改变大小:
set.seed(1002)
dat.polygon = data.frame(x = c(0,0,1,1),
y = c(0,1,1,0))
dat.marker = data.frame(id = rep(seq_len(5), 10),
x = rep(runif(5, 0, 1), 10) ,
y = rep(runif(5, 0, 1), 10),
f = rep(seq_len(10), each = 5),
r = runif(50, 1, 10))
plot_ly(x = ~x, y = ~y) %>%
add_polygons(data = dat.polygon, alpha = I(1)) %>%
add_markers(data = dat.marker, frame = ~f, ids = ~id, size = ~r) %>%
animation_opts(frame = 1000, transition = 500, redraw = FALSE)