r情节:交互式图:如何更改滑块的预设
我使用Plotly's Plot_Geo函数创建了一个Choropleth地图,并添加了一个滑块以在不同年份中循环。 如何将滑块设置为其他默认位置? 在我的示例中,我希望滑块在2005年为默认值,以便用户可以向后循环而不是向前循环。
df <- data.frame(year=c(rep(2000,5), rep(2001,5), rep(2002,5), rep(2003,5), rep(2004,5), rep(2005,5)),
stat=rep(c(4,5,6,7,3,4), 5),
location=rep(c("DEU", "BEL", "FRA", "ITA", "SWE", "FIN"),5))
plot_geo(df, frame=~year) %>%
add_trace(locations=~location, z=~stat, color=~stat) %>%
layout(geo=list(scope="europe"))
I created a choropleth map using plotly's plot_geo function and added a slider to cycle through different years.
How can I set the slider to a different default position?
In my example, I would like the slider to be at 2005 as the default, so that the user can cycle backwards instead of forward.
df <- data.frame(year=c(rep(2000,5), rep(2001,5), rep(2002,5), rep(2003,5), rep(2004,5), rep(2005,5)),
stat=rep(c(4,5,6,7,3,4), 5),
location=rep(c("DEU", "BEL", "FRA", "ITA", "SWE", "FIN"),5))
plot_geo(df, frame=~year) %>%
add_trace(locations=~location, z=~stat, color=~stat) %>%
layout(geo=list(scope="europe"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论