代码之家  ›  专栏  ›  技术社区  ›  antecessor

ggplot2雷达图中未显示的线和区域

  •  1
  • antecessor  · 技术社区  · 7 年前

    这是数据:

    structure(list(SAPvsSH = c(-23.8789646372585, NaN, -10.8009305417082, 
    -11.8411770633881, -19.000246852629, -14.364572544966, -21.8175372410621, 
    -25.4455825234135, -16.3659714913407, -24.2952691912406, -0.794961013892774, 
    9.27790872080566, -20.9411764705882, -20.3132576468705, -25.1353910061732, 
    -17.0200414318061), Tooth = c("UI1", "LI1", "UI2", "LI2", "UC", 
    "LC", "UP3", "LP3", "UP4", "LP4", "UM1", "LM1", "UM2", "LM2", 
    "UM3", "LM3")), .Names = c("error", "Tooth"), class = "data.frame", row.names = c("UI1", 
    "LI1", "UI2", "LI2", "UC", "LC", "UP3", "LP3", "UP4", "LP4", 
    "UM1", "LM1", "UM2", "LM2", "UM3", "LM3"))
    

    我用 coord_polar() ggplot 生成雷达图。这是代码:

    ggplot(data=dataset, aes(x=Tooth, y=error)) + 
      geom_point(size=1.5) + 
      geom_line() + 
      geom_hline(aes(yintercept=0), lwd=1, lty=2) + 
      geom_area(alpha=0.2, position = position_identity()) +
      coord_polar() + 
      theme_bw()
    

    我得到这样的信息:

    enter image description here

    我需要什么?

    • 追踪连接所有点的线 ( like this )与雷达在链路上的不同之处在于,这里我们只有一个组,而不是3个。

    • 为上一行定义的区域上色 以同样的方式尊重上一个图中的虚线 as here . 我们这里的参考线是黑色虚线,这很重要。

    • 将标记与外圆分开 ,以避免过度使用标记。

    • 拆下外方格 .

    0 回复  |  直到 7 年前