[R] panel/prepanel for polar plots ala xYplot

Randall Pruim rpruim at calvin.edu
Wed Feb 16 18:11:35 CET 2005


First a bit of background:

After doing a search for a flexible polar plot function and coming up 
empty, I have begun writing one myself.  Since I am new to writing 
mid-level graphics routines, this has required some learning about 
lattice, grid and related things.

I am to the point where I have a workable proof of concept, but still 
need to make some improvements.  My goal is to have something akin to a 
polar version of xYplot.  Although the particular plot I need requires 
some customization of that idea, the use of Cbind() has made that 
fairly easy.

Now some questions:

1) What are the best sources of documentation for lattice/grid?  I have 
found a few things by googling, but mostly I have been reverse 
engineering code and experimenting to figure out how things work.

2) What is the best way to generate "axis" and labels for them?

	Currently my radplot is a wrapper for xyplot that (a) turns off the 
axes and labels, and (b) calls xyplot with panel.radplot, 
prepanel.radplot, and radplot.superpose replacing the obvious things.  
I am generating the "axes" (concentric circles and peripheral labels) 
in panel.radplot, but this means that they are redrawn for each group 
when there is superposition.  Furthermore, there seems to be some 
jittering, so besides inefficiency, the result is not crisp.

	How are axes generated in xyplot?  To do this correctly will I have to 
go deeper and make a new version of trellis.skeleton or make a new call 
to it?  If I put the code into prepanel.radplot will it be executed 
once per panel or once per group in each panel?

3) I'd be happy to receive any other suggestions for how to approach 
the design of a robust, formula-based (including xYplot-like options) 
radial/polar plot.  I'd also be happy to hear of any packages that 
include something heading in this direction, if they exist and I just 
didn't locate them.

Thanks in advance for any assistance.

---rjp

PS.  For the curioius, the plot I am designing has a function call like

	radplot(Cbind(y,ratio)~x|g, groups=h, ...)

where y is numeric and x may be numeric or a factor.  The resulting 
plot has "spokes" for each value of x with length y, the last 1 - 
min(ratio, 1/ratio) fraction of the spoke rendered differently.  This 
is similar to adding error bars to a plot in xYplot -- only in polar 
coordinates.

==============================================
   Randall Pruim
   Dept. of Biostatistics, University of Michigan

   email:  rpruim at umich.edu
   phone:  734.615.9825




More information about the R-help mailing list