1

plotlyR使用parcoords情节时,我遇到了非常奇怪的错误。

例如,使用此处提供的示例:https ://plot.ly/r/parallel-coordinates-plot/

library(plotly)

df <- read.csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/iris.csv")

df %>%
  plot_ly(type = 'parcoords',
          line = list(color = ~species_id,
                      colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))),
          dimensions = list(
            list(range = c(2,4.5),
                 label = 'Sepal Width', values = ~sepal_width),
            list(range = c(4,8),
                 constraintrange = c(5,6),
                 label = 'Sepal Length', values = ~sepal_length),
            list(range = c(0,2.5),
                 label = 'Petal Width', values = ~petal_width),
            list(range = c(1,7),
                 label = 'Petal Length', values = ~petal_length)
            )
          )

结果在这个图中:

在此处输入图像描述

这是整个情节,我没有裁剪右边的图像。如果我移动轴,数据会闪烁,通常,RStudio 会崩溃。这是我的会话信息:

> sessionInfo()

R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=German_Switzerland.1252  LC_CTYPE=German_Switzerland.1252    LC_MONETARY=German_Switzerland.1252
[4] LC_NUMERIC=C                        LC_TIME=German_Switzerland.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   

和我的版本plotly

> packageVersion('plotly')
[1] ‘4.7.1’

有人遇到同样的问题吗?有针对这个的解决方法吗?

4

1 回答 1

4

问题出在 Rstudio 的查看器中。
我建议添加options(viewer=NULL)您的代码。
它禁用 RStudio 的内部查看器并在浏览器中打开您的绘图。

library(plotly)

options(viewer=NULL) 

df <- read.csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/iris.csv")   
p <- df %>%
  plot_ly(type = 'parcoords',
          line = list(color = ~species_id,
                      colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))),
          dimensions = list(
            list(range = c(2,4.5),
                 label = 'Sepal Width', values = ~sepal_width),
            list(range = c(4,8),
                 constraintrange = c(5,6),
                 label = 'Sepal Length', values = ~sepal_length),
            list(range = c(0,2.5),
                 label = 'Petal Width', values = ~petal_width),
            list(range = c(1,7),
                 label = 'Petal Length', values = ~petal_length)
          )
   )
print(p)

在此处输入图像描述

于 2017-09-12T14:28:11.770 回答