import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
df = pd.read_csv("data.tsv", index_col=0 , sep = "\t")
df = df.sort_values(by=["Women"], ascending=True)
fig, ax = plt.subplots(ncols=2, figsize=(5,8) )
plt.subplots_adjust(left=0.03, bottom=0.1, right=0.97, top=0.95, wspace=0.25)
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Noto Sans JP']
ax[0].barh(df.index, df['Men'], color='#ADD1E9', height=0.8, label='Man')
ax[0].yaxis.tick_right()
ax[0].set_xlim([90,76])
ax[0].xaxis.set_major_locator(ticker.MultipleLocator(2))
ax[1].xaxis.set_minor_locator(ticker.MultipleLocator(1))
ax[0].tick_params(axis='x', labelsize=8, rotation=15)
ax[0].tick_params(axis='y', labelsize=8)
ax[0].set_axisbelow(True)
ax[0].grid(True, which='major',color='#eeeeee',linestyle='-', axis="x")
ax[1].barh(df.index, df['Women'], color='#EED4D4', height=0.8, label='Woman')
ax[1].set_xlim([76,90])
ax[1].xaxis.set_major_locator(ticker.MultipleLocator(2))
ax[1].xaxis.set_minor_locator(ticker.MultipleLocator(1))
ax[1].tick_params(axis='x', labelsize=8, rotation=15)
ax[1].tick_params(axis='y', labelsize=8)
ax[1].set_axisbelow(True)
ax[1].grid(True, which='major',color='#eeeeee',linestyle='-', axis="x")
ax[1].axes.yaxis.set_ticklabels([])
ax[1].set_xlabel('Age',loc="right")
plt.suptitle("Life expectancy in Japan 2020, by Prefecture (MHLW)", fontsize=13)
plt.grid(which='major',color='#eeeeee',linestyle='-', axis="x", zorder=-1)
plt.grid(which='minor',color='#f3f3f3',linestyle='-', axis="x", zorder=-1)
fig.legend( facecolor="#eeeeee" , ncol=2, loc='lower center')
plt.savefig("image.svg")