r情节:交互式图:如何更改滑块的预设

发布于 2025-01-27 12:44:20 字数 510 浏览 4 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文