R ggplot geom_smooth(method = lm)在图例中添加相关性

时间:2017-07-11 09:02:13

标签: r ggplot2 legend

我有一个这样的数据框:

 d <- data.frame("accuracy" = c(0.6,0.7,0.8,0.9,.65,.78,.86,.95), 
            "size" = c(10,15,25,30,35,5,9,12),
            "classes" = c("1vs2","1vs2","1vs2","1vs2","2vs3","2vs3","2vs3","2vs3"),
            "significance"=c("1","1","1","1","1","1","2","2"),
            "percentage"=c(0.05,0.3,0.08,0.07,0.2,0.34,0.65,0.8))

我想用以下命令创建这样的情节:

 ggplot(data=d,aes(x=accuracy,y=size,color=classes)) + geom_point(aes(shape=significance,size=percentage)) + geom_smooth(method=lm,se=T,fullrange=F,aes(fill=classes))

这是目前的结果:

enter image description here

但我想为每个&#34;类&#34;添加线性模型的相关性。输入图例。 如何添加此信息? 所以在我想要的传奇中 相关 1vs2 = 0.5 2vs3 = 0.3

0 个答案:

没有答案