在R中,使用Plotly如何提取与Zoom-In工具相关的数据框架?

发布于 2025-02-06 08:43:29 字数 447 浏览 2 评论 0原文

这是我的代码:

library(gapminder)

ggplotly(ggplot(gapminder %>% filter(country == "Chile")) + aes(x = year, y = pop) + geom_line())

然后我在工具中使用Zoom:

​“> “在此处输入映像”

我的问题是:我如何访问/访问/提取与此输出相关的数据帧?

有帮助吗?

This my code:

library(gapminder)

ggplotly(ggplot(gapminder %>% filter(country == "Chile")) + aes(x = year, y = pop) + geom_line())

Then I use the zoom in tool:

enter image description here

Then I have this output:

enter image description here

My question is: How can I access/extract the dataframe related to this output?

Any help ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ヅ她的身影、若隐若现 2025-02-13 08:43:29

我想您需要这个:我们可以使用crosstalk

“在此处输入图像说明”

library(DT)
library(plotly)
library(crosstalk)
library(gapminder)

options(persistent = FALSE)

my_data <- SharedData$new(gapminder %>% filter(country == "Chile"))

my_plot <- plot_ly(my_data, x = ~ year, y = ~ pop, type = 'scatter', mode = 'lines') %>%
  add_markers(alpha = 0.5) %>%
  highlight(on = "plotly_selected", off = "plotly_deselect", dynamic = TRUE)

my_table <- datatable(my_data)

bscols(widths = c(6, 4), my_plot, my_table)

I guess you need this: We can do it with crosstalk:

enter image description here

library(DT)
library(plotly)
library(crosstalk)
library(gapminder)

options(persistent = FALSE)

my_data <- SharedData$new(gapminder %>% filter(country == "Chile"))

my_plot <- plot_ly(my_data, x = ~ year, y = ~ pop, type = 'scatter', mode = 'lines') %>%
  add_markers(alpha = 0.5) %>%
  highlight(on = "plotly_selected", off = "plotly_deselect", dynamic = TRUE)

my_table <- datatable(my_data)

bscols(widths = c(6, 4), my_plot, my_table)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文