R Plotly: Bugs in parcoords plot

1.2k views Asked by At

I'm experiencing very strange bugs when working with plotly in R when using the parcoords plot.

For example, using the example provided here: 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)
            )
          )

results in this plot:

enter image description here

This is the whole plot, I did not crop the image on the right. If I move the axes around, the data flickers on and off and usually, RStudio crashes. Here's my sessionInfo:

> 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   

and my the Version of plotly:

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

Does anybody experience the same problem? Is there a solution to this?

1

There are 1 answers

1
Marco Sandri On BEST ANSWER

The problem is in the viewer of Rstudio.
I suggest to add options(viewer=NULL) in your code.
It disables the internal viewer of RStudio and opens your plot in the browser.

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)

enter image description here