Graph 3-D Function
cone <- function(x, y){
sqrt(x^2+y^2)
}
Prepare Variables
x <- y <- seq(-1, 1, length= 20)
z <- outer(x, y, cone)
Plot the 3-D surface
persp(x, y, z)

Add Titles/Labels Colors
persp(x, y, z,
main="Perspective Plot of a Cone",
zlab = "Height",
theta = 30, phi = 15, #theta changes the amount of horizontal rotation
col = "springgreen", shade = 0.5) #phi changes the amount of vertical rotation

Another 3-d shape
newfigure <- function(x, y){
sqrt(x^3+y^2)
}
Prepare the variables
x <- y <- seq(-1, 1, length= 40)
z <- outer(x, y, newfigure)
## Warning in sqrt(x^3 + y^2): NaNs produced
Plot the shape
persp(x, y, z,
main="Perspective Plot of a New Figure",
zlab = "Height",
theta = 30, phi = 15,
col = "purple", shade = 0.5)
