Reputation: 1
I have two separate datasets that I would like to plot in both a scatterplot3d and a plot3d in r How can I do that? I can make the two plots for the datasets individually with just the following:
H <-as.numeric(Dataset$Height)
D <- Dataset$Dose
W <- Dataset$Weight
scatterplot3d(x= W,y= H, z = D,
main="Title")
plot3d(x= W,y= H, z = D, col="red", size=7 )
How can I combine the two datasets into one scatterplot3d and one plot3d? The new plots would have the same axises as the ones above. I have attached a picture to hopefully help understand the structure of the datasets
the dput looks like this:
Upvotes: -2
Views: 626
Reputation: 41260
You could add a color
column to each dataset and rbind
them :
library(scatterplot3d)
m1 <- head(mtcars,10)
m1$color <- 1
m2 <- tail(mtcars,10)
m2$color <- 2
m <- rbind(m1,m2)
W <- m$cyl
H <- m$mpg
D <- m$disp
C <- m$color
scatterplot3d(x = W, y = H, z = D,
main = "Title", color = C)
Upvotes: 0