N<-50
par(ask=TRUE)
Pre<-rnorm(N)
d<-runif(N)^2
pairedTps<-rep(0,N+1)
rankSumps<-rep(0,N+1)
for(i in 0:N){
Post<-Pre+d*c(rep(-1,i),rep(1,N-i))
plot(rep(1,length(Pre)),Pre,pch=18,col=3,xlim=c(0,3),ylim=range(c(Pre+max(d),Pre-max(d))),main="",xlab="",ylab="")
par(new=TRUE)
plot(rep(2,length(Post)),Post,pch=18,col=4,xlim=c(0,3),ylim=range(c(Pre+max(d),Pre-max(d))),main="",xlab="",ylab="")
for(j in 1:N){
segments(1,Pre[j],2,Post[j])
}
pairedTps[i+1]<-t.test(Pre,Post,paired=TRUE)$p.value
rankSumps[i+1]<-wilcox.test(Pre,Post,paired=TRUE)$p.value
}
plot(pairedTps,type="b",ylim=c(0,1),main="",xlab="",ylab="")
par(new=TRUE)
plot(rankSumps,col=2,type="b",ylim=c(0,1),main="",xlab="",ylab="")