如何在图形中单独符号化组 (R) [英] How to symbolize groups separately in a graph (R)
问题描述
我有一个小数据集,由两列数据和一列指定数据是在两个站点中的哪个站点组成的.我已经使用 xyplot
按组排序,但我无法弄清楚如何分别更改每个组的符号系统.我还需要添加一条回归线,并且只能在 plot
中弄清楚如何做到这一点.什么图形包可以在同一个图形中为我提供这些功能?
I have a small data set consisting of two columns of data and a column designating which of the two sites the data was taken at. I have used xyplot
to sort by groups, but I can't figure out how to alter the symbology of each group separately. I also need to add a regression line, and can only figure out how to do that in plot
. What graphics package can give me these features in the same graph?
我研究了不同的图形包,以找到一个我可以完成我需要的一切的包,但我是 R 新手,运气不佳.
I have looked into different graphics packages to find one in which I can do everything I need, but I am new to R and am not having much luck.
推荐答案
ggplot2 是您的首选.
ggplot2 is your go-to.
试试这个:
install.packages('ggplot2')
library(ggplot2)
one=c("A","B","A","B")
two=c(1,2,3,4)
three=c(5,7,8,20)
df<-data.frame(one,two,three)
ggplot(df,aes(x=two,y=three,col=one))+geom_line()
这篇关于如何在图形中单独符号化组 (R)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!