[R] Visualizing Points on a Sphere

2011-02-25 Thread Lorenzo Isella

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@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.


Re: [R] Visualizing Points on a Sphere

2011-02-25 Thread Duncan Murdoch

On 25/02/2011 8:21 AM, 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.



Those plots show simple linear projections of the points, after culling 
those that are on the far side of the sphere.  That's very easy for the 
points, slightly more work for the grid.  I'm not aware of any package 
that implements all of it, but you could do it yourself fairly easily.


If you want something more fancy you could use the rgl package for 3d 
plots that you can rotate.  You'll still have to draw the grid, and 
you'll probably find it a little painful to implement the hidden surface 
removal:  rgl uses depth checking to remove things, and because of 
rounding error it's not very good at drawing points and lines on 
surfaces.  (There are new options to control depth checking; see 
depth_mask and depth_test in ?material3d.  You can probably improve 
the default behaviour using those).


Duncan Murdoch

__
R-help@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.


Re: [R] Visualizing Points on a Sphere

2011-02-25 Thread Matt Shotwell
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@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.

__
R-help@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.