[R] Visualizing Points on a Sphere

Matt Shotwell matt at biostatmatt.com
Fri Feb 25 14:09:01 CET 2011


That's interesting. You might also like:
http://en.wikipedia.org/wiki/Von_Mises%E2%80%93Fisher_distribution

I'm not sure how to plot the wireframe sphere, but you can visualize the
points by transforming to Cartesian coordinates like so:

u <- runif(1000,0,1)
v <- runif(1000,0,1)
theta <- 2 * pi * u
phi   <- acos(2 * v - 1)
x <- sin(theta) * cos(phi)
y <- sin(theta) * sin(phi)
z <- cos(theta)
library("lattice")
cloud(z ~ x + y)

-Matt

On Fri, 2011-02-25 at 14:21 +0100, Lorenzo Isella wrote:
> Dear All,
> I need to plot some points on the surface of a sphere, but I am not sure 
> about how to proceed to achieve this in R (or if it is suitable for this 
> at all).
> In any case, I am not looking for really fancy visualizations; for 
> instance you can consider the images between formulae 5 and 6 at
> 
> http://bit.ly/hOgK9h
> 
> Any suggestion is appreciated.
> Cheers
> 
> Lorenzo
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list