3

I'm using a polar plot to describe satellite position during a time series. The following question uses the polar.plot function from the R package plotrix. An example plot:

library(plotrix)
polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
                          point.symbols=19,radial.lim=c(0,5),boxed.radial=F)

The issues I'm running across is that this function plots the labels and axis over the data values (see radial positions 0 and 3), and I don't see a way to control this behavior. I can run a workaround by adding the data values again (adding to the previous plot) with axis and labels turned off, but this is less than elegant:

polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
           grid.left=F,point.symbols=19,show.radial.grid=FALSE,
           show.grid.labels=FALSE,show.grid=FALSE,labels=NULL,add=TRUE)

My question is two fold:

  1. Is there a way to control this in plotrix that I've missed in the documentation?
  2. Is there another package that can easily handle this kind of azimuth polar plot?
Nate
  • 768
  • 3
  • 9
  • 17
  • Why are you using `boxed.radial=F`? – agstudy Mar 11 '13 at 20:24
  • 1
    `boxed.radial=F` makes the boxes around the radial labels transparent. It helps by not completely obscuring a point that is behind the label, but it does not change the overplotting by the axes lines. – Nate Mar 12 '13 at 01:25

2 Answers2

3

You can control the way those radial labels are displayed with two parameters: show.grid.labels and radial.labels. See ?radial.plot for more complete information.

show.grid.labels accepts values from 1 to 4 (similar to that of pos or axis, see ?par or ?axis) controlling the side on which they are displayed. radial.labels accepts a vector of labels, so if you want the labels to be turned down: radial.labels = "" works,

library(plotrix)
polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
           point.symbols=19,radial.lim=c(0,5),boxed.radial=FALSE, 
           show.grid.labels=2)

enter image description here

polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
           point.symbols=19,radial.lim=c(0,5),boxed.radial=FALSE, 
           show.grid.labels=2, radial.labels=c("",1:5))

enter image description here

You can also get rid of the axial lines using show.radial.grid:

polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
           point.symbols=19,radial.lim=c(0,5),boxed.radial=FALSE, 
           show.grid.labels=2, radial.labels=c("",1:5), 
           show.radial.grid=FALSE)

enter image description here

However there doesn't seem to be a way of making the lines lie behind the labels and the points, so if you do want the lines to appear behind then your original idea was probably the best:

polar.plot(NA,NA,start=90,clockwise=TRUE,rp.type="",
           radial.lim=c(0,5),boxed.radial=FALSE, show.grid.labels=2,
           radial.labels=c("",1:5)) # First plotting the grid
polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",
           point.symbols=19,radial.lim=c(0,5),show.grid=FALSE, 
           show.radial.grid=FALSE, add=TRUE)  # Then the points without the grid

enter image description here

I don't know of any other package having a function handling this kind of plot, however if you want to create your own function, this answer to your previous question can definitely help you start.

Community
  • 1
  • 1
plannapus
  • 18,529
  • 4
  • 72
  • 94
  • Thanks for the comments, I am aware of the flags you mentioned. Your comments pretty much sum up where I am at. Regarding my previous question, I have done a quick test with that approach, and it could work with a bit of rewrite. I had hoped, as with so much of R, someone out there had nicely packaged the easy stuff and I had just not found it. – Nate Mar 12 '13 at 16:16
  • They already packaged the "hard" part (the plot itself). Polishing the aesthetic is part of the user's job I think. Remember the "someone out there" you mentioned is you and me the Users. Maybe you could suggest the authors of package plotrix (some of them are active members of StackOverflow, BenBolker for instance) some changes to include in the next release. – plannapus Mar 13 '13 at 07:03
0

This seems to have been fixed. I've not looked at the change log to determine where the change happened, but it is fixed as of at least plotrix 3.5-12.

library(plotrix)
polar.plot(c(0,1,3,4),c(30,60,90,120),start=90,clockwise=TRUE,rp.type="s",point.symbols=19,radial.lim=c(0,5),boxed.radial=F,grid.col="red",point.col="green")

polar.plot

Currently the axes are plotted correctly under the data points. The labels are (reasonably) plotted on top. The overplot option discussed above would work well if it is necessary to have the data overlay the labels.

Nate
  • 768
  • 3
  • 9
  • 17