[R] Changing origin of line in radial plot

Jim Lemon jim at bitwrit.com.au
Thu Oct 28 11:42:27 CEST 2010


On 10/28/2010 07:14 AM, Gonzalo Garcia-Perate wrote:
> I am creating radial plots to visualise popularity of a series of
> topics, I was wondering if someone has come across a radial plot in
> which the lines originate from the edge of the plot instead of the
> centre, does anyone know how can this be achieved in R? Are there any
> good reasons not to do it?
>
Hi Gonzalo,
This is an interesting suggestion. I suppose it could be done with an 
"invert" routine that swapped the center coordinates for those of the 
outer ring of the annular grid for each radial line. I think I have seen 
something like this to illustrate some sort of genetic information.

Yep, down about line 139 in my code you could define xposmax and yposmax 
if the new argument "invert" was TRUE, then

if(invert) {
  xposmax<-cos(radial.pos[i,])*maxlength
  yposmax<-sin(radial.pos[i,])*maxlength
}
if(match("r",rptype,0)) {
  if(invert)
   segments(xposmax,yposmax,xpos,ypos,
    col=linecol,lty=ltype,lwd=lwidth,...)
  else
   segments(0,0,xpos,ypos,col=linecol,
    lty=ltype,lwd=lwidth,...)

Untested, but it might do what you want.

Jim



More information about the R-help mailing list