Adding error bars to plotrix polar plot

691 views Asked by At

I have been trying for quite some time to create error bars in a polar plot using plotrix. While the scatter function were no issue, I was unable to add the error bars, because when I add for example the lines with a second polar plot with radian mode, I cannot move them away from the center of the plot to start at the scatter point... my best guess was to add a second polar plot on top, with a radian of the scatterplot point + the error bars, and then add a white line on top of that, with scatterplot point - error bars, covering up the error bar up to the lower limit... This is obviously not only very ugly in code, but also in the graph, so I was wondering, whether there is a better solution for that. My code so far (using mtcars as a nonsensical example) looks like this:

 library(plotrix)

polar.plot(mtcars$mpg, polar.pos=NULL, start=90,clockwise=TRUE,rp.type="s", 
    point.symbols=19, point.col="black",show.grid=TRUE, show.radial.grid=FALSE,
    show.grid.labels=TRUE,boxed.radial=FALSE, radial.lim=c(0,40))

polar.plot(mtcars$mpg+mtcars$gear, polar.pos=NULL, start=90,clockwise=TRUE,
    rp.type="r", point.symbols=16,show.grid.labels=TRUE,boxed.radial=FALSE, 
    radial.lim=c(0,40), add=TRUE, lwd=3)

polar.plot(mtcars$mpg-mtcars$gear, polar.pos=NULL, start=90,clockwise=TRUE,
     rp.type="r", point.symbols=16,show.grid.labels=TRUE,boxed.radial=FALSE,
     radial.lim=c(0,40), add=TRUE, lwd=4, line.col="white")

enter image description here

0

There are 0 answers