import numpy as np
import pandas as pd
from pandas import Series,DataFrame
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import csv
from scipy.interpolate import interp1d
import locale
import japanize_matplotlib
encoding = locale.getpreferredencoding()
plt.rcParams['figure.subplot.bottom'] = 0.25
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twinx()
covid = pd.read_csv('nhk_news_covid19_domestic_daily_data.csv')
df = DataFrame(covid)
df_s=df.set_index("日付")["2020/3/1":]
df_r = df_s.reset_index()
# num = df_rの行数(rows)
num = len(df_r)
df0 = pd.DataFrame(df_r)
ax1.bar(df0["日付"],df0["国内の感染者数_1日ごとの発表数"], label="国内の感染者数_1日ごとの発表数",color='royalblue',width=1.0,align="center")
ax1.xaxis.set_major_locator(mdates.DayLocator(interval=50))
ax1.tick_params(axis='x', colors ="black", rotation = 90)
ax1.tick_params(axis='y', colors ="navy")
#---------------------------------------
ax2.bar(df0["日付"],df0["国内の死者数_1日ごとの発表数"], label="国内の死者数_1日ごとの発表数", color='red',width=0.7,align="center")
ax2.xaxis.set_major_locator(mdates.DayLocator(interval=50))
ax2.tick_params(axis='y', colors ="red")
ax2.set_ylim(0,)
plt.xlim(0, num)
handler1, label1 = ax1.get_legend_handles_labels()
handler2, label2 = ax2.get_legend_handles_labels()
ax1.legend(handler1+handler2,label1+label2,borderaxespad=0)
ax1.grid(axis='x')
plt.grid()
plt.show()