5

我一直在尝试通过使用 plotly 和 crosstalk 库来生成交互式链接可视化。如下例所示,似乎可以将 ggplot2 传递给“共享数据框”对象,以便使用 ggplotly() 生成链接视图。当我尝试运行此示例时,我收到以下错误消息:

错误:ggplot2 不知道如何处理 SharedData/R6 类的数据

我正在使用当前版本的 ggplot2 (v. 2.2.1) 和 plotly (4.5.6)。什么会导致此错误?

谢谢帮助!

我试图复制的例子可以在这里找到:

https://cpsievert.github.io/plotly_book/linking-animated-views.html

library(gapminder)
library(crosstalk)
library(ggplot2)
library(plotly)

g <- crosstalk::SharedData$new(gapminder, ~continent)

gg <- ggplot(g, aes(gdpPercap, lifeExp, color = continent, frame = year)) +
  geom_point(aes(size = pop, ids = country)) +
  geom_smooth(se = FALSE, method = "lm") +
  scale_x_log10()
  ggplotly(gg) %>% 
  highlight("plotly_hover")

  Error: ggplot2 doesn't know how to deal with data of class SharedData/R6
4

0 回答 0