diff --git a/python/population_plot.py b/python/population_plot.py index 1fe3bee..17a8719 100644 --- a/python/population_plot.py +++ b/python/population_plot.py @@ -4,19 +4,26 @@ import numpy as np # Initial population population = 1_000_000 death_rate = 0.10 -years = np.arange(0, 1001, 100) # 0 to 1000 years in 100-year intervals +years = np.arange(4000, 10001, 500) # 4000 to 10000 years in 500-year intervals -# Calculate population after each 100-year interval -population_values = [population] -for year in years[1:]: - population -= death_rate * population +# Calculate population after each 500-year interval +population_values = [] +for year in years: + # Apply the death rate for each 500-year period (5 times for each interval) + for _ in range(5): + population -= death_rate * population population_values.append(population) -# Create the graph +# Create the graph with labels for each data point plt.figure(figsize=(8, 6)) plt.plot(years, population_values, marker='o', linestyle='-', color='b') plt.xlabel('Years') plt.ylabel('Population') -plt.title('Population Projection') +plt.title('Population Projection from Year 4000') + +# Adding labels to the data points +for i, txt in enumerate(population_values): + plt.annotate(f"{int(txt):,}", (years[i], population_values[i]), textcoords="offset points", xytext=(0,10), ha='center') + plt.grid(True) plt.show()