Submitted by : Rahul Swami
Language : R
Downloader: 13
Posted on : 05-05-2019 02:44:59p

Download Code

In R programming there are various function for creating 3D plots. we discuss the persp( ) function for creating the 3D surfaces.

There are three variables, x , y and z where x and y are the vectors that define the location of x-axis and y-axis. The height of surface will be definig z-axis.


cone <- function(x, y)   #cone obtained the function

x <- y <- seq(-1, 1, length= 20)  #variables
z <- outer(x, y, cone)

persp(x, y, z)

seq()  -  to generate vector of equally spaced numbers.

outer() - to apply the function cone at every combination of x and y.