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

时间:2018-07-05 16:53:39

标签: r ggplot2

这是数据:

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 个答案:

没有答案