在R中使用ggplot2添加多个线段?

时间:2017-01-25 22:06:29

标签: r ggplot2

我在向图表添加一些趋势线时遇到了困难。

p<-ggplot(rawdata,aes(V8,V9,color=V9)) + geom_point()

 for(i in 1:length(means))
{
     p + (geom_segment(aes(x = rawdata[boundary[i],8], y = means[i], xend = rawdata[boundary[i],8], yend = means[i])))
}

Means是一个向量,包含迭代时每个不同边界的均值。

我没有收到任何错误,但细分未出现在情节中。

该脚本旨在根据数据集输入的大小进行扩展,因此for循环。

0 个答案:

没有答案