import matplotlib.pyplot as plt
from cycler import cycler
import pandas as pd
import matplotlib.ticker as ticker
df = pd.read_csv("data.tsv", index_col=0 , sep = "\t")
df1 = df.T.loc['Share of GDP'] # line
df2 = df.T.loc['per person'] # bar
fig, ax = plt.subplots(figsize=(8,4))
ax2 = ax.twinx()
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Noto Sans Display']
plt.subplots_adjust(left=0.09, bottom=0.13, right=0.92, top=0.92)
plt.setp(ax.get_xticklabels(), fontsize=7)
plt.setp(ax.get_yticklabels(), fontsize=8)
ax.bar(df2.index, df2, color="#E69717", width=0.6, label="Health expenditure per person")
ax.tick_params(axis='x', labelrotation=50)
ax.set_ylabel("per person (1000 JPY)", fontsize=9)
ax.set_ylim([0,400])
ax2.set_ylabel("% of GDP", fontsize=9)
ax2.set_ylim([0,20])
ax2.set_prop_cycle( plt.rcParams['axes.prop_cycle'] )
ax2.plot(df1, label="% of GDP")
lines, labels = ax.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()
ax2.legend(lines + lines2, labels + labels2, facecolor="#eeeeee" ,fontsize=10, ncol=1, loc='upper left')
ax.xaxis.set_major_locator(ticker.MultipleLocator(3))
plt.title("National health expenditure in Japan (MHLW)", fontsize=14)
plt.tick_params(labelsize=9, pad=4)
plt.setp(ax.get_yticklabels(), fontsize=8 )
plt.setp(ax2.get_yticklabels(), fontsize=8 )
ax.patch.set_alpha(0)
ax.minorticks_on()
ax.set_axisbelow(True)
ax.grid(True, which='major',color='#cccccc',linestyle='-', axis="y")
ax.grid(True, which='minor',color='#eeeeee',linestyle='--', axis="y")
ax2.grid(False, which='both', axis="both")
plt.savefig("image.svg")