Search code examples
rplotradialplotrix

Change the circumferential radial grid segment lines color in the radial.plot function. Plotrix


I have two datasets which contain values for a radial plot and colors for the radial grid lines of this plot.

First dataset:

#data 1
values  <- c(0.179615044,  0.011908401, -0.342792441,  -0.154263864,
           -0.251553369, -0.234413350,   0.150411419)
colors <- c("black", "black", "red", "red", "red", "black", "black")

Second dataset:

#data 2
values  <- c(0.88582075,  0.80089077,  0.79452764,  0.77835694, -0.06816896, 0.24024556, -0.02023557, 
              0.28804668, -0.88184648,  0.93711689)


colors <- c("red",  "red",   "red",   "red", "black", "black", "black", "black", "red",   "red")

When I make the radial plots with the following function, I get plots with either colored circular grid lines or non colored circular grid lines. Both plots have the correct radial grid lines colored red.

library(plotrix)

#plotrix radial plot
radial.plot(values, grid.col=colors, rp.type="p")

How do I get the radial grid lines the get colored and not the circular grid lines? Is grid.col the wrong argument the use here?

correct image from dataset 1 (black circular grid + highlighted radial grid lines):

https://i.sstatic.net/p66Mt.png

incorrect image from dataset 2 (red circular grid + highlighted radial grid lines):

https://i.sstatic.net/uzchS.png


Solution

  • I have found a bug in the radial.plot code. The new code fixes this problem and only colors the radial segment lines.

    For the code: https://github.com/kroeliebuschie/radial.plot/blob/master/radial.plot.R

    A new argument (seg.col) specifies the radial segment lines.

    #seg.col specifies the line colors
    radial.plot(values, seg.col=colors, rp.type="p")
    

    edit

    The circumferential lines can be changed now. Jim Lemon has added this feature and has called it grid.col

    see link: http://www.inside-r.org/packages/cran/plotrix/docs/radial.plot