[R] Colouring a grid segment

darrenh65 darren.hennessy at advitech.com.au
Fri Oct 9 01:47:48 CEST 2009


Thanks for the reply Jim,
I didn't think of that but polar.plot seems to have a couple of quirks. The
first is if I try your idea using c(rep(maxlength,40)) as the lengths it
does not work, the grid is not even displayed, no error info is given. I
solved that by adding an additional point to the vectors:
  c(0,rep(maxlength,40))
  c(0,seq(start,end,length.out=40))

The other one I have no idea whats going on. If I add another plot after the
'new=TRUE' to display the real data it doesn't plot the grids the same size
even with the maximum length set the same. Vertically the grids are the
same, horizontally they aren't. Here is a simple script to demonstrate:

require(plotrix)
max<-10
start<-30
end<-50
len<-c(0,rep(max,50))
pos<-c(0,seq(start,end,length.out=50))
lbl<-seq(0,350,by=22.5)

polar.plot(len,pos,main="Test Plot",start=90,clockwise=TRUE,
rp.type='p',labels='',label.pos=lbl,
              line.col='red',poly.col='red')

par(new=TRUE)

datalen<-c(0,seq(0,max,length.out=35))
datapos<-seq(0,350,by=10)
polar.plot(datalen,datapos,main="Test Plot",start=90,clockwise=TRUE,
rp.type='s',labels='',label.pos=lbl)

Any thoughts?
Darren


Jim Lemon-2 wrote:
> 
> 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
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Colouring-a-grid-segment-tp25797407p25813511.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list