import matplotlib as mpl
from cycler import cycler
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("data.tsv", index_col=0 , sep = "\t")
df = df.sort_values(by=["Total"], ascending=True)
df = df.drop("Total", axis=1)
df = df.T
mpl.rcParams['axes.xmargin'] = 0.02
fig, ax = plt.subplots(figsize=(12, 6))
for i in range( len(df) ):
ax.bar(df.columns, df.iloc[i] , width=0.7, bottom=df.iloc[:i].sum())
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Noto Sans Display']
plt.subplots_adjust(left=0.06, bottom=0.26, right=0.98, top=0.93)
plt.title("Revenue of Government 2020 (OECD Revenue)", fontsize=16)
plt.tick_params(labelsize=10, pad=4)
ax.legend(df.index, fontsize=9, ncol=3, loc='center' ,bbox_to_anchor=(0., -0.34, 1, 0.102) , facecolor="#dddddd"
, title_fontsize=9)
ax.set_axisbelow(True)
plt.xticks(df.columns, rotation=45, size=9)
plt.yticks(fontsize=9)
plt.ylabel("Tax revenue as % of GDP", size=11)
plt.ylim([0,50])
ax.minorticks_on()
plt.grid(which='major',color='#999999',linestyle='-', axis="y")
plt.grid(which='minor',color='#dddddd',linestyle='--', axis="y")
plt.savefig("image.svg")