could not find function "snapshot3d"

Hi all,
I have tried to extract a figure in 3d using the snapshot3d function but the error is could not find function snapshot3d.
This is my code:
library(csn)
library(scatterplot3d) ;
library(mvtnorm);library(Matrix);library(csn);library(expm);
library(Perc);library(surface);library(rgl);library(MASS);
library(plot3D)
library(rgl)

set.seed(4321)
n<- 700
mu <- c(0,0)
sigma <- matrix(c(2,0.2,0.2,4),2)
gamma <- matrix(c(4,0,0,5),2)
nu <- c(-2,6)
delta <- matrix(c(1,0,0,1),2)

X1<- rcsn(n, mu, sigma, gamma, nu, delta)
t.kde <- kde2d(X1[,1], X1[,2], n = 50)
x <- seq(-5,5,length=n);y=x;
persp3d(x=t.kde,theta = 60, phi = 90, axes=TRUE,label=TRUE, nticks=5,col="blue")
#snapshot3d(file.path("C:/Users/the path of my desktop", "sim.png") , top = TRUE )
###########
Another way I did to extract the figure is this line
snapshot3d( "C:/Users/....", ..., scene, width = NULL, height = NULL,
webshot = rgl.useNULL())
snapshot3d(my script name, fmt = "png", top = TRUE)

but still in both ways I cannot extract this figure. Any idea please? Thank you.

Hi @Lamia ,
You may have already solved this but if not:

library(csn)
# library(scatterplot3d)
# library(mvtnorm)
# library(Matrix)
# library(expm)
# library(Perc)
# library(surface)
library(rgl)
library(MASS)
library(plot3D)
library(webshot2)   # Needed to include this package

set.seed(4321)
n <- 700
mu <- c(0,0)
sigma <- matrix(c(2,0.2,0.2,4),2)
gamma <- matrix(c(4,0,0,5),2)
nu <- c(-2,6)
delta <- matrix(c(1,0,0,1),2)

X1 <- rcsn(n, mu, sigma, gamma, nu, delta)
t.kde <- kde2d(X1[,1], X1[,2], n = 50)

str(t.kde)
#> List of 3
#>  $ x: num [1:50] -0.875 -0.731 -0.587 -0.443 -0.299 ...
#>  $ y: num [1:50] 0.875 0.995 1.114 1.234 1.354 ...
#>  $ z: num [1:50, 1:50] 0.00497 0.00993 0.01676 0.02396 0.02925 ...

persp3d(x=t.kde, 
        theta = 60, phi = 90, axes=TRUE, label=TRUE, nticks=5, col="blue")


# Requires {webshot2} and Chrome browser, see (help(snapshot3d))
# Image is only from one angle and is not interactive.
snapshot3d(file.path("C:/Users/david/Desktop", "sim.png") , webshot = TRUE )

Created on 2022-12-11 with reprex v2.0.2

Hope this helps.

2 Likes

Thank you so much yes it does.

This topic was automatically closed 7 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.