Files
scripts/python/population_plot.py
Dobromir Popov 88becd9fe0 4000 to 1k
2023-12-16 21:43:00 +00:00

30 lines
958 B
Python

import matplotlib.pyplot as plt
import numpy as np
# Initial population
population = 1_000_000
death_rate = 0.10
years = np.arange(4000, 10001, 500) # 4000 to 10000 years in 500-year intervals
# 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 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 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()