import matplotlib.pyplot as plt
import pandas as pd
from cycler import cycler
df = pd.read_csv("data.tsv", index_col=0 , sep = "\t")
df = df.T
fig, ax = plt.subplots(figsize=(16, 8))
ax.bar(df.index, df["-19"] , width=0.7)
ax.bar(df.index, df["20-24"], width=0.7, bottom=df["-19"] )
ax.bar(df.index, df["25-29"] , width=0.7, bottom=df["-19"] + df["20-24"] )
ax.bar(df.index, df["30-34"], width=0.7, bottom=df["-19"] + df["20-24"] + df["25-29"] )
ax.bar(df.index, df["35-39"], width=0.7, bottom=df["-19"] + df["20-24"] + df["25-29"]+ df["30-34"] )
ax.bar(df.index, df["40-44"], width=0.7, bottom=df["-19"] + df["20-24"] + df["25-29"]+ df["30-34"] +df["35-39"])
ax.bar(df.index, df["45+"], width=0.7, bottom=df["-19"] + df["20-24"] + df["25-29"]+ df["30-34"] +df["35-39"] + df["40-44"])
ax.legend(df.columns, fontsize=15, ncol=7, loc='center' ,bbox_to_anchor=(0., -0.20, 1., .102) , title="Age of Mother", title_fontsize=15)
ax.set_axisbelow(True)
ax.set_ylim([0,100])
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Noto Sans Display']
plt.subplots_adjust(left=0.07, bottom=0.17, right=0.99, top=0.92)
plt.title("Live births in Japan, by Age of Mother (MHLW Vital statistics)", fontsize=22)
plt.tick_params(labelsize=10, pad=4)
plt.ylabel("Percentage", size=18)
plt.xticks(rotation=60,fontsize=11)
plt.yticks(fontsize=15)
plt.minorticks_on()
plt.grid(which='major',color='#999999',linestyle='-', axis="y")
plt.grid(which='minor',color='#cccccc',linestyle='--', axis="y")
plt.savefig("image.svg")