【发布时间】:2015-07-25 02:44:02
【问题描述】:
我有这种情况,我正在绘制一系列线条,如下所示:
library(foreach)
library(ggplot2)
df.test <- foreach(ix = seq(0,1,by=0.01),.combine=rbind) %do% {
theta = seq(-pi,pi,by=pi/100)
data.frame(IX=ix,theta=theta,value=ix*sin(theta))
}
ggplot(df.test,aes(x=theta,y=value,color=IX,group=IX,order=-IX)) + geom_path() +
theme_bw() + labs(x="Theta",y="Sin(Theta)",color="Index",title="Example Plot") +
theme(legend.position=c(0,1),legend.justification=c(0,1))
生成如下图:
如果仔细观察原点,高索引值(浅蓝色)的值会堆叠在低索引值(深蓝色)的行之上。
我怎样才能扭转这种情况,使深蓝色线(低指数)堆叠在浅蓝色线(高指数)之上。
以上内容类似于我的实际问题,我正在绘制各种温度的科学数据。低温值比高温值更有意义,所以我不希望低温线被高温线潜在地掩盖,实际上相反是我的偏好。
【问题讨论】: