diff --git a/age.py b/age.py new file mode 100644 index 0000000..de12b60 --- /dev/null +++ b/age.py @@ -0,0 +1,21 @@ +import matplotlib.pyplot as plt +import pandas as pd + + + +def age(): + data = pd.read_csv("data/age.csv") + + lables = data['age'] + title = [1991, 2001, 2011] + plt.suptitle('Distribution of ages') + for num in range(3): + years = data[str(title[num])]/100000 + plt.subplot(1,3,num+1) + plt.bar(lables, years) + plt.tick_params(gridOn=True) + plt.tick_params(grid_alpha = 190) + plt.tick_params(labelsize=6) + plt.tick_params(labelrotation=45) + + plt.title(title[num]) \ No newline at end of file diff --git a/data/age.csv b/data/age.csv new file mode 100644 index 0000000..b07cbdf --- /dev/null +++ b/data/age.csv @@ -0,0 +1,9 @@ +age,1991,2001,2011 +0-14,3273482,4492939,4565319 +15-19,914871,1427979,1667375 +20-24,982866,1426860,1764060 +25-29,956788,1358925,1668326 +30-39,1438035,2211006,2753943 +40-49,867731,1432467,2008410 +50-59,504149,759505,1196361 +60,439520,719650,1147445 diff --git a/data/area.csv b/data/area.csv new file mode 100644 index 0000000..dc5788d --- /dev/null +++ b/data/area.csv @@ -0,0 +1,4 @@ +Year,Rural,Urban,Total +1991,797.66,685.34,1483 +2001,558.32,924.68,1483 +2011,369.35,1113.65,1483 diff --git a/data/population.csv b/data/population.csv new file mode 100644 index 0000000..e0687fd --- /dev/null +++ b/data/population.csv @@ -0,0 +1,15 @@ +Year,Population,GrowthRate,Growth +2019,29399141,0.0325,3533266 +2015,25865875,0.033,3877980 +2010,21987895,0.033,3296565 +2005,18691330,0.0356,2999431 +2000,15691899,0.0527,3553666 +1995,12138233,0.0528,2754024 +1990,9384209,0.0537,2158451 +1985,7225758,0.0528,1638744 +1980,5587014,0.0472,1150629 +1975,4436385,0.0467,905692 +1970,3530693,0.0441,685651 +1965,2845042,0.045,562080 +1960,2282962,0.0508,501338 +1955,1781624,0.054,412255 diff --git a/data/sex_ratio.csv b/data/sex_ratio.csv new file mode 100644 index 0000000..dd8ac93 --- /dev/null +++ b/data/sex_ratio.csv @@ -0,0 +1,10 @@ +Category,region,2001,2011 +State,Uttarakhand,962,963 +State,Chandigarh,777,818 +State,Rajasthan,921,928 +State,Haryana,861,879 +State,J&K,892,889 +State,Punjab,876,895 +State,UP,898,912 +State,HP,968,972 +Union Territory,Delhi,821,868 diff --git a/population.py b/population.py new file mode 100644 index 0000000..ec427ae --- /dev/null +++ b/population.py @@ -0,0 +1,10 @@ +import matplotlib.pyplot as plt +import pandas as pd + + +def population(): + data = pd.read_csv("data/population.csv") + plt.plot(data["Year"], data["Population"]/10000000) + plt.title('Population of Delhi (1955 to 2019)') + plt.xlabel('Year') + plt.ylabel('Population\n(crore)') \ No newline at end of file diff --git a/sex_ratio.py b/sex_ratio.py new file mode 100644 index 0000000..529e922 --- /dev/null +++ b/sex_ratio.py @@ -0,0 +1,29 @@ +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np + + + +def sex_ratio(): + data = pd.read_csv("data/sex_ratio.csv") + + lables = data['region'] + year2001 = data['2001'] + year2011 = data['2011'] + + index = np.arange(len(lables)) + width = 0.4 + + fig, ax = plt.subplots() + rects1 = ax.bar(index - width/2, year2001, width, label='2001') + rects2 = ax.bar(index + width/2, year2011, width, label='2011') + + for tick in ax.xaxis.get_major_ticks(): + tick.label.set_fontsize(8) + + ax.set_ylabel('No of females per 1000 males') + ax.set_title('Sex Ratio of northern states 2001 & 2011') + ax.set_xticks(index) + ax.set_xticklabels(lables) + fig.autofmt_xdate() + ax.legend() \ No newline at end of file diff --git a/urbanisation.py b/urbanisation.py new file mode 100644 index 0000000..5e701c0 --- /dev/null +++ b/urbanisation.py @@ -0,0 +1,25 @@ +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np + + + +def urbanisation(): + data = pd.read_csv("data/area.csv") + + lables = data['Year'] + urban = data['Urban'] + rural = data['Rural'] + + index = np.arange(len(lables)) + width = 0.4 + + fig, ax = plt.subplots() + rects1 = ax.bar(index - width/2, rural, width, label='Rural') + rects2 = ax.bar(index + width/2, urban, width, label='Urban') + + ax.set_ylabel('Sq. Km') + ax.set_title('Area - Rural and Urban') + ax.set_xticks(index) + ax.set_xticklabels(lables) + ax.legend() \ No newline at end of file diff --git a/visualisation.py b/visualisation.py new file mode 100644 index 0000000..ca8dfae --- /dev/null +++ b/visualisation.py @@ -0,0 +1,46 @@ +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np + +import urbanisation +import sex_ratio +import population +import age + + +def show_menu(): + print() + print("1. Rapid Urbanisation") + print("2. Population") + print("3. Sex Ratio") + print("4. Age distribution") + print("5. Exit") + print() + +def show_graph(): + plt.tick_params(gridOn=True) + plt.tick_params(grid_alpha = 190) + plt.show() + + +print("Welcome to our project.") +print("A visualisation of Demographics of Delhi.") + +while True: + show_menu() + choice = int(input("Enter your choice: ")) + + if choice == 1: + urbanisation.urbanisation() + elif choice == 2: + population.population() + elif choice == 3: + sex_ratio.sex_ratio() + elif choice == 4: + age.age() + elif choice == 5: + break + else: + print("Invalid choice.\n") + + show_graph() \ No newline at end of file