In [1]:
# Librerie
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
get_ipython().magic('pylab inline')
In [2]:
# Cartelle Input/Output
dir_df = os.path.join(os.path.abspath(''),'stg')
dir_out = os.path.join(os.path.abspath(''),'output')
In [3]:
df_g6_filename = r'df_g6.pkl'
df_g6_fullpath = os.path.join(dir_df, df_g6_filename)
df_g6 = pd.read_pickle(df_g6_fullpath)
df_g6 = df_g6.set_index(['Anno'])
In [27]:
style.use('fivethirtyeight')
# Colorblind-friendly colors
colors = [[0,0,0], [230/255,159/255,0]]
tp = df_g6.plot(
kind='line',
legend = False,
figsize = (6,4),
color = colors,
linewidth=1)
tp.tick_params(axis = 'both', which = 'major', labelsize = 10)
tp.set_ylabel('% poveri sul totale',fontsize=8)
tp.set_xlabel('Anno di riferimento',fontsize=8)
tp.axhline(y = 0, color = 'black', linewidth = 0.8, alpha = 0.7)
#tp.axvline(x = 00, color = 'black', linewidth = 4, alpha = 0.7)
text = tp.text(x = -0.8, y = -3,
s = 'www.ildatomancante.it Istat - 2015',
fontsize = 10, color = '#f0f0f0', backgroundcolor = 'grey')
# Adding a title and a subtitle
tp.text(x = -0.5, y = 12.5, s = "Percentuale poveri sul totale",
fontsize = 14, weight = 'bold', alpha = .75)
tp.text(x = -0.5, y = 11.2,
s = "Rapporto tra il numero di individui in condizione di povertà assoluta e \nil numero individui residenti.",
fontsize = 10, alpha = .85)
# Add colored labels
tp.text(x = 7, y = 5.7, s = 'Nord', color = colors[0], weight = 'bold', rotation = 0,
backgroundcolor = 'None',fontsize = 10)
tp.text(x = 6.3, y = 7.5, s = 'Sud', color = colors[1], weight = 'bold', rotation = 30,
backgroundcolor = 'None',fontsize = 10)
fig_posts = tp.get_figure()
fig_posts.tight_layout()
fig_posts.savefig(os.path.join(dir_out,'G6_Tassi_Povertà.png'), format='png', dpi=1000)