Plotting curves and points on and around a sphere


Before using the following routine you must set the sphere position and orientation with sphinit.

Curves and points are plotted on a sphere using the routine sphplot. For the examples below:
The background is set to some value by a statement like:
erase, 60
The sphere is initialized by a statement like:
sphinit, long=-30, lat=40, rad=1, fill=40, pa=30

At some point you may want to better understand how the sph* routines handle clipping and hidden lines.


The built-in help for sphplot is:
 Plot a curve in spherical polar coordinates.
 sphplot, lng, lat, rad
   lng = array of longitudes.     in
   lat = array of latitudes       in
   rad = array of radii.          in
 Keywords:
   COLOR=c  plot color.
   LINESTYLE=s  plot linestyle.
     Over-rides defaults for visible and hidden points.
   THICK=t  plot thickness.
   /HIDDEN plot hidden points.
   /ALL ignore visible hemisphere clipping, plot all.
   MAXRAD=r clip points using a sphere of radius r.
   /XYZ  allows the call: sphplot, x, y, z, /xyz.
   PSYM=p  set plot symbol.
   SYMSIZE=s  set symbol size.
   XOUT=x  returns array of plotted data coordinate X.
   YOUT=y  returns array of plotted data coordinate Y.
   PEN=p   returns array of pen codes for XOUT, YOUT.
 Notes: Call SPHINIT first to set sphere orientation and
   point clipping to the visible hemisphere (def=front).
   Point clipping may alternatively be done using a
   clipping sphere defined by MAXRAD.

Spirals around a sphere

Window setup

   window, xs=300, ys=300
   !p.position=[0,0,1,1]
   set_isoxy, -1.1, 1.1, -1.1, 1.1
   loadct, 4
   erase, 80
Sphere setup
   sphinit, long=-30, lat=40, rad=.4, fill=140, pa=30
Set up a curve in space
  lng = makex(0,90,2)
  lat = lng*0
  rad = maken( .9, .4, n_elements(lat)) 
Plot multiple copies of the curve, shift each
  for a = 0, 360, 10 do sphplot, lng+a, lat, rad, maxrad=.4

Spirals on a sphere

    lat = maken(-90, 90, 200) 
    lng = maken(0, 360*2, 200)   
    rad = fltarr(200)+1.
    c = maken(50, 180, 30)
    erase, 80
    sphinit, long=-30, lat=40, rad=1, fill=0, pa=30
    for i=0, 29 do sphplot, lng+i*12, lat, rad, color=c(i), thick=2
    sphinit, long=-30, lat=40, rad=1, pa=30

    erase
    sphinit, long=-30, lat=40, pa=30
    for i= 0, 29 do sphplot, lng+i*12, lat, $
      rad+sin(lng/!radeg*30)*.03, color=c(i), thick=2


Return the Spherical Sketch Pad Routines main menu