1
如何防止出现错误的箭头?当使用facet_grid时,geom_segment会产生错误的箭头
x<-seq(-2,2,by=0.1)
df<-rbind(data.frame(x,y=sin(x),type="sin"),data.frame(x,y=cos(x),type="cos"))
ggplot(df,aes(x,y))+
geom_point()+
facet_grid(. ~ type)+
geom_segment(aes(xend=c(tail(x, n=-1), NA), yend=c(tail(y, n=-1), NA)),arrow=arrow(length=unit(0.2,"cm")))
[R 3.3.2
ggplot2_2.2.1