【问题标题】:y-axis limits of radar plot雷达图的 y 轴范围
【发布时间】:2016-07-02 12:24:10
【问题描述】:

我的问题使用了以下示例: 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)

如何定义 y 轴的限制?目前,最低值将位于雷达图的中间,不会显示零。我希望零在中间而不是图的中间/中心是最低值。

非常感谢任何帮助!

【问题讨论】:

    标签: r ggplot2 limits radar-chart ggproto


    【解决方案1】:

    我发现它只是简单地工作

      scale_y_continuous(limits=c(0,10), breaks=c(1,2,3,4,5,6,7,8,9,10))
    

    ...但我必须事先将值更改为 as.numeric。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      • 2020-04-05
      • 1970-01-01
      • 2018-10-09
      相关资源
      最近更新 更多