2

I have used the following example for my question: http://www.cmap.polytechnique.fr/~lepennec/R/Radar/RadarAndParallelPlots.html

mtcarsscaled <- as.data.frame(lapply(mtcars, ggplot2:::rescale01))
mtcarsscaled$model <- rownames(mtcars)
mtcarsmelted <- reshape2::melt(mtcarsscaled)

coord_radar <- function (theta = "x", start = 0, direction = 1) 
{
  theta <- match.arg(theta, c("x", "y"))
  r <- if (theta == "x") 
    "y"
  else "x"
  ggproto("CordRadar", CoordPolar, theta = theta, r = r, start = start, 
          direction = sign(direction),
          is_linear = function(coord) TRUE)
}

plot <- ggplot(mtcarsmelted, aes(x = variable, y = value)) +
  geom_polygon(aes(group = model, color = model), fill = NA, size = 2, show.legend = FALSE) +
  geom_line(aes(group = model, color = model), size = 2) +
  theme(strip.text.x = element_text(size = rel(0.8)),
        axis.text.x = element_text(size = rel(0.8)),
        axis.ticks.y = element_blank(),
        axis.text.y = element_blank()) +
  xlab("") + ylab("") +
  guides(color = guide_legend(ncol=2)) +
  coord_radar()

print(plot)

How can I change the color of the outermost line of the plot/grid (the line underneath the y-labels)?

Any help is much appreciated!

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
Stücke
  • 868
  • 3
  • 14
  • 41

1 Answers1

0

That line is unfortunately controlled with the grid.major argument, but is not an explicit break. The only way I've found to do this is by cancelling the rest of the breaks like so:

ggplot(mtcarsmelted, aes(x = variable, y = value)) +
  geom_polygon(aes(group = model, color = model), fill = NA, size = 2, show.legend = FALSE) +
  geom_line(aes(group = model, color = model), size = 2) +
  theme(strip.text.x = element_text(size = rel(0.8)),
        axis.text.x = element_text(size = rel(0.8)),
        axis.ticks.y = element_blank(),
        axis.text.y = element_blank(),
        panel.grid.major.y = element_line(colour = "blue", size = 0.2), #changed
  xlab("") + ylab("") +
  guides(color = guide_legend(ncol=2)) +
  scale_y_continuous(breaks = NULL) + #changed
  coord_radar()

Which gives:

enter image description here

Unfortunately you lose the ability to have a y grid (which to be honest if you are not labeling in a polar grid is not that important anyway). You can alter the colour with the colour argument in element_line

Chris
  • 6,302
  • 1
  • 27
  • 54