3D Scatterplot not showing up in web browser

I am trying to follow the tutorial here before I create some 3D scatterplots of my own.

# library
library(rgl)
options(rgl.printRglwidget = TRUE)

# This is to output a rgl plot in a rmarkdown document. Note that you must add webgl=TRUE, results='hide' in the chunck header
library(knitr)
knit_hooks$set(webgl = hook_webgl)

# Data: the iris data is provided by R
data <- iris

# Add a new column with color
mycolors <- c('royalblue1', 'darkcyan', 'oldlace')
data$color <- mycolors[ as.numeric(data$Species) ]

# Plot
par(mar=c(0,0,0,0))
plot3d( 
  x=data$`Sepal.Length`, y=data$`Sepal.Width`, z=data$`Petal.Length`, 
  col = data$color, 
  type = 's', 
  radius = .1,
  xlab="Sepal Length", ylab="Sepal Width", zlab="Petal Length")


writeWebGL( filename="3dscatter.html" ,  width=600, height=600)

However, after doing this, 2 things seem to happen. First, I get these warnings:

Warning messages:
1: In snapshot3d(scene = x, width = width, height = height) :
  webshot = TRUE requires the webshot2 package; using rgl.snapshot() instead
2: In rgl.snapshot(filename, fmt, top) :
  this build of rgl does not support snapshots

I do not know what it means by snapshot since that is not in my code. The second thing is after I run, a file named 3dscatter.html shows up in my working directory, but I go to the browser, I do not see my plot. Javascript is enabled. Would someone please help me figure out what I am missing here?

enter image description here

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.