Solutions Touch
← Back to all blogs

August 19, 2019

3D Plot in R

By Rahul Swami

3D Plot in R

you will learn to create 3D plots.

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
{
   sqrt(x^2+y^2)
}

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.

 

interactive 3d plot in r r 3d surface plot ggplot2 r 3d scatter plot multiple linear regression 3d plot in r r 3d line plot scatter 3d r 3d bar plot in r 3d histogram r 3D Plot in R r 3d plot plot in r