I'm trying to get the scatterplot3d package of R to render within a Beaker Notebook, but cannot get it to work. I can run the code without error, but the graphic is not displayed. Setting the scatterplot3d output to a variable and printing the variables gets:
input:
data(iris)
test <- scatterplot3d(iris[,1:3])
test
output:
$xyz.convert
function (x, y = NULL, z = NULL)
{
xyz <- xyz.coords(x, y, z)
if (angle > 2) {
temp <- xyz$x
xyz$x <- xyz$y
xyz$y <- temp
}
y <- (xyz$y - y.add)/y.scal
return(list(x = xyz$x/x.scal + yx.f * y, y = xyz$z/z.scal +
yz.f * y))
}
<environment: 0x00000000048f8830>
$points3d
function (x, y = NULL, z = NULL, type = "p", ...)
{
xyz <- xyz.coords(x, y, z)
if (angle > 2) {
temp <- xyz$x
xyz$x <- xyz$y
xyz$y <- temp
}
y2 <- (xyz$y - y.add)/y.scal
x <- xyz$x/x.scal + yx.f * y2
y <- xyz$z/z.scal + yz.f * y2
mem.par <- par(mar = mar, usr = usr)
on.exit(par(mem.par))
if (type == "h") {
y2 <- z.min + yz.f * y2
segments(x, y, x, y2, ...)
points(x, y, type = "p", ...)
}
else points(x, y, type = type, ...)
}
<environment: 0x00000000048f8830>
$plane3d
function (Intercept, x.coef = NULL, y.coef = NULL, lty = "dashed",
lty.box = NULL, ...)
{
if (!is.atomic(Intercept) && !is.null(coef(Intercept)))
Intercept <- coef(Intercept)
if (is.null(lty.box))
lty.box <- lty
if (is.null(x.coef) && length(Intercept) == 3) {
x.coef <- Intercept[if (angle > 2)
3
else 2]
y.coef <- Intercept[if (angle > 2)
2
else 3]
Intercept <- Intercept[1]
}
mem.par <- par(mar = mar, usr = usr)
on.exit(par(mem.par))
x <- x.min:x.max
ltya <- c(lty.box, rep(lty, length(x) - 2), lty.box)
x.coef <- x.coef * x.scal
z1 <- (Intercept + x * x.coef + y.add * y.coef)/z.scal
z2 <- (Intercept + x * x.coef + (y.max * y.scal + y.add) *
y.coef)/z.scal
segments(x, z1, x + y.max * yx.f, z2 + yz.f * y.max, lty = ltya,
...)
y <- 0:y.max
ltya <- c(lty.box, rep(lty, length(y) - 2), lty.box)
y.coef <- (y * y.scal + y.add) * y.coef
z1 <- (Intercept + x.min * x.coef + y.coef)/z.scal
z2 <- (Intercept + x.max * x.coef + y.coef)/z.scal
segments(x.min + y * yx.f, z1 + y * yz.f, x.max + y * yx.f,
z2 + y * yz.f, lty = ltya, ...)
}
<environment: 0x00000000048f8830>
$box3d
function (...)
{
mem.par <- par(mar = mar, usr = usr)
on.exit(par(mem.par))
lines(c(x.min, x.max), c(z.max, z.max), ...)
lines(c(0, y.max * yx.f) + x.max, c(0, y.max * yz.f) + z.max,
...)
lines(c(0, y.max * yx.f) + x.min, c(0, y.max * yz.f) + z.max,
...)
lines(c(x.max, x.max), c(z.min, z.max), ...)
lines(c(x.min, x.min), c(z.min, z.max), ...)
lines(c(x.min, x.max), c(z.min, z.min), ...)
}
<environment: 0x00000000048f8830>
I'm not sure if this functionality is possible with Beaker Notebooks, but thought I check here if anyone has any tips.
Thanks,
-pH+
Figured it out. As part of my code, I was changing the working directory of R to more easily pull in datafiles from my project folder via:
setwd("C:/Users/macle/Desktop/UPC Masters/Semester 1/CN/MAI-CN/Final Project")
It appears that somewhere along the way, this breaks the ability of scatterplot3d to display the output in a Beaker Notebook.
I've instead just used absolute paths to load the files I need, which has solved the issue for me.
@spot Thanks for pointing me in the right direction and confirming the issue was on my end and not a limitation of Beaker.
Ps. I love working with Beaker, thanks for developing such a fantastic tool.