0

I am in the process of making a nice graph but I encountered an issue with the extremities of the lines I drew. I do not know why R does not plot the lines all the way until maxxx (10 here). You can see on the graph from the code below what I am talking about (I cannot put picture as my reputation is too low), the extremities of the lines stop before 10:

maxxx<-10
plot(0,type="n",axes=FALSE,xlim=c(0,10),ylim=c(0,10),ylab="",xlab="")
mtext("TROLOLOL",side=3,cex=3)
axis(1,pos=0,at=c(0,10),labels=FALSE)
mtext("R1 ",side=1,line=0,cex=3)
axis(2,pos=0,at=c(0,10),labels=FALSE)
mtext("R2",side=2,line=0,cex=3)


Given_growth_rates<-c(0,0.3,0.5,1,2,5);


K1<-7
g1<-5.5
m<-0.2
R1_isoclines<-numeric(length(Given_growth_rates))
for (i in 1:length(Given_growth_rates)){
R1_isoclines[i]<-((Given_growth_rates[i]+m)*K1)/(g1-Given_growth_rates[i]-m)
}
R1_isoclines

K2<-10
g2<-7
R2_isoclines<-numeric(length(Given_growth_rates))
for (i in 1:length(Given_growth_rates)){
R2_isoclines[i]<-((Given_growth_rates[i]+m)*K2)/(g2-Given_growth_rates[i]-m)
}
R2_isoclines

for (i in 1:length(R1_isoclines)){
lines(rep(R1_isoclines[i],times=length(R2_isoclines[i]:maxxx)), R2_isoclines[i]:maxxx,             col=i+1, type="l")
lines(R1_isoclines[i]:maxxx,rep(R2_isoclines[i],times=length(R1_isoclines[i]:maxxx)),col=i+1,type="l")
}
4

1 回答 1

1

尝试将代码的最后四行替换为:

for (i in 1:length(R1_isoclines)){
    lines(rep(R1_isoclines[i],times=2), c(R2_isoclines[i],maxxx), col=i+1, type="l")
    lines(c(R1_isoclines[i], maxxx), rep(R2_isoclines[i],times=2),col=i+1,type="l")
}

在此处输入图像描述

也许这符合您的期望。

于 2013-10-02T12:30:56.567 回答