How to plot a three dimensional sphere in R based on center and radius?

r 3d rgl
Jeromy Anglim picture Jeromy Anglim · Aug 23, 2012 · Viewed 8.2k times · Source

How can one plot a sphere in R by providing a center point and a radius?

For example, something like this:

sphere_3d(center=c(1,1,1), r=2))

The plot would appear on a three dimensional coordinate system.

Answer

mdsumner picture mdsumner · Aug 23, 2012

Try spheres3d in the rgl package for an interactive plot:

library(rgl)
spheres3d(x = 1, y = 1, z = 1, radius = 1)

There are many other ways, so what's going to be useful needs more input.