I would like to create plot something like this :
Here we have two variables X = midyear and Y = yearend. I would like to create density plot for each level of X for Y.
I could go to this point, but do not look pretty like what I have in mind particularly angle of the plot and line. Any idea to make such twist or other packages that can do.
set.seed(1234)
m50 <- rnorm(10000, 51, 5)
d50 <- hist(m50, breaks = 100)$density
md50 <- hist(m50, breaks = 100)$mids
m70 <- rnorm(10000, 73, 5)
d70 <- hist(m70, breaks = 100)$density
md70 <- hist(m70, breaks = 100)$mids
m90 <- rnorm(10000, 90,5)
d90 <- hist(m90, breaks = 100)$density
md90 <- hist(m90, breaks = 100)$mids
density = c(d50, d70, d90)
yearend = c(md50, md70, md90)
midyear = c(rep(50, length(d50)), rep(70, length(d70)), rep(90, length(d90)))
df <- cbind(midyear, yearend, density)
require(scatterplot3d)
s3d <- scatterplot3d(df, type = "h", color = "blue",
angle = 80, scale.y = 0.7, xlim = c(40, 100),
zlim = c(0,0.2), pch = ".", main = "Adding elements")
Edits: Using rgl package
require(rgl)
s3d <- plot3d(df, type = "h",
angle = 80, scale.y = 0.7, xlim = c(40, 100),
zlim = c(0,0.15), pch = ".", main = "Adding elements")