4000 to 1k
This commit is contained in:
@ -4,19 +4,26 @@ import numpy as np
|
|||||||
# Initial population
|
# Initial population
|
||||||
population = 1_000_000
|
population = 1_000_000
|
||||||
death_rate = 0.10
|
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
|
# Calculate population after each 500-year interval
|
||||||
population_values = [population]
|
population_values = []
|
||||||
for year in years[1:]:
|
for year in years:
|
||||||
population -= death_rate * population
|
# 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)
|
population_values.append(population)
|
||||||
|
|
||||||
# Create the graph
|
# Create the graph with labels for each data point
|
||||||
plt.figure(figsize=(8, 6))
|
plt.figure(figsize=(8, 6))
|
||||||
plt.plot(years, population_values, marker='o', linestyle='-', color='b')
|
plt.plot(years, population_values, marker='o', linestyle='-', color='b')
|
||||||
plt.xlabel('Years')
|
plt.xlabel('Years')
|
||||||
plt.ylabel('Population')
|
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.grid(True)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
Reference in New Issue
Block a user