Closing the lines in a ggplot2 radar / spider chart

后端 未结 6 1994
时光取名叫无心
时光取名叫无心 2020-12-16 07:11

I need a flexible way to make radar / spider charts in ggplot2. From solutions I\'ve found on github and the ggplot2 group, I\'ve come this far:

library(ggpl         


        
6条回答
  •  渐次进展
    2020-12-16 07:58

    Using the new ggproto mechanism available in ggplot2 2.0.0, coord_radar can be defined as:

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

    Not sure if the syntax is perfect but it is working...

提交回复
热议问题