【发布时间】:2018-06-19 21:57:43
【问题描述】:
我正在尝试使用 ggplot2 中的 geom_path 根据方向对箭头进行颜色编码。我在单独的行中有多年的数据,并且想要一个从最早的数据点指向最近的数据点的箭头,用颜色描绘方向,使其更容易解释。这些点按 Lake_ID 分组,因为每年都有多行,所以我遇到了麻烦。
这是基本数据:
Lake_ID Year Gear psd BioVolume
16 2012 EF 0.370967742 0.095585695
16 2012 GN 1 0.095585695
16 2012 TN 0 0.095585695
16 2012 Whole 0.375 0.095585695
16 2017 EF 0.214285714 0.100623115
16 2017 GN 1 0.100623115
16 2017 TN 0 0.100623115
16 2017 Whole 0.179487179 0.100623115
ggplot(blg.dup.year,aes(BioVolume,psd,group=Lake_ID,label=Year))+
geom_point(aes(BioVolume,psd,colour=Year))+theme_bw()+
facet_grid(Gear~.,scales = "free_y")+
labs(title="Bluegill PSD",y="PSD",x="Littoral BioVolume")+
geom_path(arrow=arrow(angle=30,length=unit(0.1,"inches"),
type="closed"),aes(group=Lake_ID))
谢谢!
【问题讨论】: