import matplotlib.pyplot as plt import numpy as np %matplotlib inline N = 100 C = np.zeros(N) # consumption Y = np.zeros(N) # income C[0] = 100 Y[0] = 100 print(C) for t in range(1, N): C[t] = Y[t-1] # calculate spending based on earlier income Y[t] = C[t] # calculcate income earned in this time period # create a figure fig = plt.figure(figsize=(8, 4)) # create a subplot for consumption consumption_plot = fig.add_subplot(121) # plot consumption (C) versus time step (N) consumption_plot.plot(range(N), C, lw=3) # add gridlines consumption_plot.grid() # label axes plt.xlabel('time') plt.ylabel('consumption') # create a second subplot for income income_plot = fig.add_subplot(122) # plot income (Y) versus time step (N) income_plot.plot(range(N), Y, lw=3) # add gridlines income_plot.grid() # label axes plt.xlabel('time') plt.ylabel('income') # space subplots neatly plt.tight_layout()