[R] Colouring a grid segment

Jim Lemon jim at bitwrit.com.au
Thu Oct 8 08:39:25 CEST 2009


On 10/08/2009 01:15 PM, darrenh65 wrote:
> Hi,
> I am attempting to create a polar chart (using plotrix polar.plt) and I need
> to colour a segment of the grid to indicate an area of interest, say from
> 90-120 degrees, for arguments sake. Is this possible? I can colour the whole
> grid by passing the grid.bg parameter through to radial.plot but I cannot
> find a way to colour a segment.
>
> thanks,
> Darren
>    
Hi Darren,
You're right, there isn't any way to color just one sector of the 
background in a polar.plot. That's the bad news. The slightly less bad 
news is that I think you can kludge it by calling polar.plot twice with 
par(new=TRUE) between. First do the plot without the sector, noting the 
maximum extent of the grid ("maxlength" in the code). Then plot the 
polygon by calling the function so:

polar.plot(c(rep(maxlength,40)),
  polar.pos=seq(start,end,length.out=40),rp.type="p",...)
par(new=TRUE)

(you may want more than 40 points) Then plot your real data on top of 
this. I can't test this right now, but will try it out in the next day 
or so.

Jim




More information about the R-help mailing list