Data visualisations made by Janhavi Pimplikar
A student at Pimpri Chinchwad College of Engineering
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly as py
import cufflinks as cf
import plotly.express as px
from plotly.offline import iplot
cf.go_offline()
py.offline.init_notebook_mode(connected=True)
world=pd.read_csv('Stats.csv')
world['Population (2019)']=world['Population (2020)']-world['Net Change']
world
fig=px.choropleth(world,locations='Country (or dependency)',locationmode='country names', color=np.log(world['Population (2020)']),hover_name='Population (2019)',color_continuous_scale=px.colors.sequential.Magma,title='World Population distribution (2019)')
fig.update(layout_coloraxis_showscale=True)
fig.show()
fig=px.choropleth(world,locations='Country (or dependency)',locationmode='country names', color=np.log(world['Population (2020)']),hover_name='Population (2020)',color_continuous_scale=px.colors.sequential.Viridis,title='World Population distribution (2020)')
fig.update(layout_coloraxis_showscale=True)
fig.show()
top_10=world.head(10)
top_10.iplot(x='Country (or dependency)',y=['Population (2019)','Population (2020)'],kind='bar',xTitle='Country',yTitle='Population',title='Most populous countries in 2019 and 2020',legend=True, color=['pink','green'])
bottom_10=world.tail(10)
bottom_10.iplot(x='Country (or dependency)',y=['Population (2019)','Population (2020)'],kind='bar',xTitle='Country',yTitle='Population',title='Least populous countries in 2019 and 2020',legend=True, color=['blue','orange'])
fig=px.choropleth(world,locations='Country (or dependency)',locationmode='country names', color=np.log(world['Population (2020)']),hover_name='Population (2020)',color_continuous_scale=px.colors.sequential.Inferno,title='World Population density distribution')
fig.update(layout_coloraxis_showscale=True)
fig.show()
top_10.iplot(x='Country (or dependency)',y='Density (P/Km²)',kind='bar',xTitle='Country',yTitle='Population density',title='Most densely populated countries',legend=True, color='green')
bottom_10.iplot(x='Country (or dependency)',y='Density (P/Km²)',kind='bar',xTitle='Country',yTitle='Population',title='Least densely populated countries',legend=True, color='orange')
urban=world[['Country (or dependency)','Urban Pop %']].sort_values('Urban Pop %',ascending=False)
urban=urban.head(25)
fig,ax=plt.subplots(figsize=(15,15))
lab=urban['Country (or dependency)']
urban.plot.pie(y='Urban Pop %',ax=ax,legend=False,labels=lab,colors=sns.color_palette('Accent'),autopct="%1.2f%%",fontsize=10,shadow=True)
plt.title('25 countries having the highest urban population',size=20)
c=plt.Circle((0,0),0.3,color='white')
plt.gca().add_artist(c)
fig.show()
land=world[['Country (or dependency)','Land Area (Km²)']].sort_values('Land Area (Km²)',ascending=False)
land=land.head(25)
fig,ax=plt.subplots(figsize=(15,15))
lab=land['Country (or dependency)']
land.plot.pie(y='Land Area (Km²)',ax=ax,legend=False,labels=lab,colors=sns.color_palette('Set2'),autopct="%1.2f%%",fontsize=10,shadow=True)
plt.title('25 countries having the largest land area',size=20)
c=plt.Circle((0,0),0.3,color='white')
plt.gca().add_artist(c)
fig.show()
dataset: imported from https://www.kaggle.com/kisoibo/countries-databasesqlite
attributes: Websites such as stackoverflow.com, matplotlib.com etc.