How to fix scale on matplot lib graphs

Viewed 29

Apologies if this is a bit of a dumb question, I'm a nursing major who's been thrown a bit in the deep end! For one of my courses, I am required to graph an SIR model given certain parameters and formulas. I've checked the parameters and formulas many times and the scale of my graph is wildly distorted for a population of 75000. The x axis is supposed to be scaled from 0-50 weeks by 7ths, and I'm not getting that at all either. What is going on and how do I prevent this from occurring in the future?

N=75000
S=np.zeros(75000)
I=np.zeros(75000)
R=np.zeros(75000)
I[0]=0.5
S[0]=N-I[0]
R[0]=0
lamb=5.6
beta=8*(10^-5)*N
dt=1/7
for n in range(349): ##50 weeks
  S[n+1]=S[n]-dt*(beta*((S[n]*I[n])/N))
  S[n+1]=S[n]-(dt*beta*((S[n]*I[n])/N))
  I[n+1]=I[n]+dt*(beta*((S[n]*I[n])/N)-(lamb*I[n]))
  R[n+1]=R[n]+(dt*lamb*I[n])

plt.plot(S)
plt.plot(I)
plt.plot(R)
plt.xlabel("weeks")
plt.ylabel("# of individuals")
plt.text(20,200,"I")
plt.text(10,10,"S")

This is what my graph looks like currently, which even I can recognize to be wildly incorrect. The y axis should never see negative numbers! very wrong graph

Thank you so much for your assistance!

0 Answers
Related