O'Reilly logo

R for Data Science by Dan Toomey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating 3D graphics

One of the built-in functions to generate 3D graphics is persp. The persp function draws perspective plots of a surface over the x-y plane. The persp function has many optional parameters and will likely produce the graphics that you need. As a test, you can use the following example function, and it will generate three 3D graphics:

> example(persp)

This function call will generate three graphics.

(Included in the output are all of the commands necessary to generate the graphics.)

The first generated image shows a 3D plot of a rotated sine function. The associated R commands (also generated for you) are as follows:

> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")

Here's the first generated image:

The next ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required