Let's take very simple data:
x1 <- sample(1:100, 10)
x2 <- runif(10)
y <- rnorm(10)
I want to make a 3D plot (x1, x2, y) but I cannot find any function how it can be performed in R. I found function perp
but perp(x1, x2, y)
simply returns error, that x
and y
is not increasing. Could you please give me a hand doing so?
CodePudding user response:
You can simply use cloud function from lattice package
install.packages("lattice")
library("lattice")
cloud(x1~ x2 y)
you can add some options also
cloud(x1~ x2 y ,
xlab= "x1" ,
ylab = "x2" ,
zlab = "y" ,
main="3D plot of X1 x2 and Y " ,
pch=16 ,
aspect = c(1,1) ,
panel.aspect = 1 ,
screen = list(z=105 , x=70))
CodePudding user response:
you can have a look at plotly
:
library(plotly)
plot_ly( x = x1, y = x2, z = y)