import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as ticker
df = pd.read_csv("data.tsv", index_col=0 , sep = "\t")
fig, ax = plt.subplots(figsize=(10, 5))
ax.bar(df.index, df["Pension"] , color="#D676AB", width=0.7, bottom=0)
ax.bar(df.index, df["Health"], color="#9BBB59", width=0.7, bottom=df["Pension"] )
ax.bar(df.index, df["Welfare,etc"], color="#CB9CFB", width=0.7 , bottom=df["Pension"]+df["Health"] )
ax.legend(df.columns, fontsize=12, ncol=3, loc='upper left', frameon=True, facecolor="#dddddd")
ax.set_axisbelow(True)
ax.yaxis.set_major_locator(ticker.MultipleLocator(20))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Noto Sans Display']
plt.subplots_adjust(left=0.08, bottom=0.12, right=0.96, top=0.92)
plt.title("Social expenditure of Japan (MHLW,2022)", fontsize=16)
plt.tick_params(labelsize=10, pad=4)
plt.xticks(df.index, rotation=75, fontsize=7)
plt.yticks(fontsize=9)
plt.ylabel("Trillion JPY", fontsize=12)
plt.margins(0.02)
plt.ylim([0,190])
plt.minorticks_on()
plt.grid(which='major',color='#cccccc',linestyle='-', axis="y")
plt.grid(which='minor',color='#eeeeee',linestyle='-', axis="y")
plt.savefig("image.svg")