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

StackOverflow https://stackoverflow.com/questions/18229385

  •  24-06-2022
  •  | 
  •  

Pregunta

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):

http://i.imgur.com/5e9mJys.png

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

http://i.imgur.com/NRFPetY.png

¿Fue útil?

Solución

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

Otros consejos

Try the line.col argument like this:

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

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


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

library(plotrix)

#plotrix radial plot
radial.plot(values2, line.col = colors2, grid.col = "black", rp.type = "p")

This generates the image below:

screenshot

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top