在ggplot中添加一个额外的点

时间:2014-02-03 20:41:51

标签: r ggplot2

这个问题是对这篇文章的后续跟进:previous post

我有28个变量 M1,M2,...,M28 ,我为此计算了某些统计数据 x < / strong>和 y

 library(ggplot2)
 df = data.frame(model = factor(paste("M", 1:28, sep = ""), levels=paste("M", 1:28, sep = "")), a = runif(28, 1, 1.05), b = runif(28, 1, 1.05))

 levels = seq(0.8, 1.2, 0.05)

这是情节:

 ggplot(data=df) + 
   geom_polygon(aes(x=model, y=a, group=1), color = "black", fill = NA) + 
   geom_polygon(aes(x=model, y=b, group=1), color = "blue", fill = NA) +
   coord_polar() + 
   scale_y_continuous(limits=range(levels), breaks=levels, labels=levels) +
   theme(axis.text.y = element_blank(), axis.ticks = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank())

我想在 M1(model1)中为 y-value = 1 添加一个点。我尝试添加:

 geom_point(aes(y = 1, x = "M1"), color = "red", cex = 0.5)

但它不起作用。知道我做错了吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

cex不是geom_point的参数。试试size,例如

geom_point(aes(y = 1, x = "M1"), color = "red", size = 10)

enter image description here