Is there an alternative to 'abline' for 3D scatterplot? I'm using 'scatterplot3d' package.
The blue line in the image is what I want to do. If I add a 'surface', then it will block the original plot.
Something like this?
th <- seq(0,8*pi,len=100)
r <- seq(0,1,len=100)
x <- r*cos(th)
y <- r*sin(th)
z <- 10*r
library(scatterplot3d)
plt <- scatterplot3d(x,y,z, type="l")
plt$points3d(x=c(-1,1,1,-1,-1), y=c(1,1,-1,-1,1),z=rep(5,5), type="l", col="blue", lwd=2)
The basic idea is to capture the object returned by sactterplot3d(...)
. This is a list, one element of which is a function, points3d(...)
which can add points (or lines with type="l"
) to the existing plot.