Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3d scatter plot remains empty in R plotly

Tags:

r

3d

plotly

I have a simple question regarding a 3d scatter plot using the plotly package in R. It appears all of the plots are working with the exception of the 3d scatter and line plots. To test this I've tried the following code (= taken from the cheat sheet):

library(plotly)

plot_ly(type = "scatter3d", x = c(9,8,5,1), y = c(1,2,4,8),z = c(11,8,15,3),
        mode = "markers")

enter image description here

I ended up with a plot containing only the axis and not the actual points. To troubleshoot I've added colors which got me confused as the legend with the color scale did appear but not the points themselves. I did notice the axis have the wrong scale ((80,-80),(60,-60),(100,-100)).

Furthermore, the 3d surface plot en 2d scatter plot examples worked perfectly.

like image 793
Viktor Avatar asked May 04 '17 10:05

Viktor


People also ask

Which Plotly method is used to create a 3D scatter plot?

3D scatter plot with Plotly Express. Plotly Express is the easy-to-use, high-level interface to Plotly, which operates on a variety of types of data and produces easy-to-style figures. Like the 2D scatter plot px. scatter , the 3D function px.


1 Answers

(Posted on behalf of the OP).

I reverted to the older package (4.5.6 was found to be working), please find the script below:

require(devtools)
install_version("plotly", version = "4.5.6", repos = "http://cran.us.r-project.org")
like image 161
halfer Avatar answered Oct 17 '22 00:10

halfer