1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
create<- function(number=10, alive=1, locx=1,locy=1)
{
inds<-data.frame(alive=rep(alive, number),
x=rep(locx,number), y=rep(locy,number))
inds
}
mesinds=create()
mesinds$x=runif(10)
mesinds$y=runif(10)
a=seq(0.1,0.5,0.0001)
b=seq(0.499,0.1,-0.0001)
c=c(a,b)
f=as.vector(c)
fin=rep(f,20)
nruns=200
X11()
for (i in 1:nruns)
{
for (j in 1:length(fin)){
mesinds$x<-runif(10); mesinds$y<-runif(10)
if (fin[j]>0.17 & fin[j]<0.35 ){
if (mesinds$x<0.5+fin[j] & mesinds$x>0.5-fin[j] & mesinds$y>0.5-fin[j] & mesinds$y<0.5+fin[j]) {
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="red",main=paste("automne/printemps"),xlab="",ylab="")
title(sub = "Infection selon les saisons", x.sub = 0.75, font.sub = 3)
}
else {
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="blue",main=paste("automne/printemps"),xlab="",ylab="")
title(sub = "Infection selon les saisons", x.sub = 0.75, font.sub = 3)
}
symbols(0.5,0.5,circles=fin[j],inches=F,add=T,fg="green")
}
if(fin[j]<0.17){
if (mesinds$x<0.5+fin[j] & mesinds$x>0.5-fin[j] & mesinds$y>0.5-fin[j] & mesinds$y<0.5+fin[j])
{
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="red",main=paste("hiver"),xlab="",ylab="")
title(sub = "Infection selon les saisons ", x.sub = 0.75, font.sub = 3)
}
else {
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="blue",main=paste("hiver"),xlab="",ylab="")
title(sub = "Infection selon les saisons", x.sub = 0.75, font.sub = 3)
}
symbols(0.5,0.5,circles=fin[j],inches=F,add=T,fg="green")
}
if(fin[j]>0.35){
if (mesinds$x<0.5+fin[j] & mesinds$x>0.5-fin[j] & mesinds$y>0.5-fin[j] & mesinds$y<0.5+fin[j]) {
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="red",main=paste("été"),xlab="",ylab="")
title(sub = "Infection selon les saisons ", x.sub = 0.75, font.sub = 3)
}
else {
plot(mesinds$x,mesinds$y,ylim=c(0,1),xlim=c(0,1),cex=3,col="blue",main=paste("été"),xlab="",ylab="")
title(sub = "Infection selon les saisons ", x.sub = 0.75, font.sub = 3)
}
symbols(0.5,0.5,circles=fin[j],inches=F,add=T,fg="green")
}
}
} |
Partager