【问题标题】:Plotly R subplot by group produces error (identical code to example)Plotly R subplot by group 产生错误(与示例代码相同)
【发布时间】:2016-04-08 17:56:36
【问题描述】:

我实际上是从 plotly R 示例页面复制并粘贴此代码,它会产生错误。似乎无法使其正常工作。

iris$id <- as.integer(iris$Species)
p <- plot_ly(iris, x = Petal.Length, y = Petal.Width,
             group = Species,
             xaxis = paste0('x', id), mode = 'markers')
p <- subplot(p)
Error in locator(2) : plot.new has not been called yet
p
Warning message:
In par(old.par) : calling par(new=TRUE) with no plot

这是我正在使用的包版本:

packageVersion('plotly')
[1] ‘3.4.13’

有什么想法吗?

【问题讨论】:

  • 适用于 plotly_3.4.3 ggplot2_2.1.0
  • 我正在使用来自 Github 的开发版本,因为在该版本而不是 CRAN 版本中修复了 subplot 中的错误。我认为 CRAN 的最新版本是 3.4.1。有什么办法可以通过从 github 安装降级到 3.4.3?没试过。
  • 这也是我正在使用的开发版本,但比你的旧 :-)
  • 对....在我安装了 3.4.9 dev 的另一台机器上试过,这似乎也有效。在最近的开发版本中必须打破某些东西。刚刚在 Github 上提交了问题报告。谢谢。
  • 经过进一步检查,plotly::subplot() 被 Hmisc::subplot() 覆盖,这是我在 cut2() 代码中使用的一个包。道歉。

标签: r plotly


【解决方案1】:

在我的版本上工作,根据.9000 判断,我在 github 开发版本上,但无论如何我相信最后一次 plot_ly 更新使用dplyr 和管道系统。

packageVersion('plotly')
> '4.5.6.9000'

iris %>%
    group_by(Species) %>%
    do(p = plot_ly(., x = ~Petal.Length, y = ~Petal.Width, name = ~Species)) %>%
    subplot()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多