[R] Plot a sphere

Derick Schoonbee schoonbee at hotmail.com
Fri Dec 26 00:07:06 CET 2003


Hi,

I'm new to R (and math ;) Would somebody please be so kind as to direct me 
in plotting a 3D sphere?

I tried something in the lines of:
####
y <- x <- seq(-pi, pi, length=pi*10)
f <- function(x,y)
{
	z <- sqrt(pi - x^2 - y^2)
	#z[is.na(z)] <- 0
	z
}
z <- outer(x, y, f)

persp(x, y, z, theta = 120, phi = 30)
####

I've also tried: .... make.surface.grid(...) .. persp( as.surface( grid, z) 
) ... with the same result: 'Incomplete' demi sphere and others..

Any suggestions/solutions would be appreaciated.

Regards,
Derick

PS:Merry X-mas ;)




More information about the R-help mailing list