import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns; sns.set() df = pd.read_csv("data/applemobilitytrends-2020-04-13.csv") #cn_list = ("Japan", "Tokyo", "Osaka", "Nagoya", "Fukuoka") cn_list = ("Japan", "United States", "UK", "Germany", "Italy") df = df[df['region'].isin(cn_list)] transportation_type = ("driving", "transit", "walking") fig = plt.figure(figsize=(15,15)) fig.subplots_adjust(hspace=0.5) data_title = "Apple Maps Mobility Trends Reports" for i, tt in enumerate(transportation_type, 1): tmp = df[df['transportation_type'] == tt].iloc[:,3:-1] tmp.index = df[df['transportation_type'] == tt][ 'region'] tmp = tmp.transpose() tmp.index = pd.to_datetime(tmp.index) ax = fig.add_subplot(3,1,i) tmp.plot(ax=ax) ax.set_title(tt + " - " + data_title) ax.set_ylim(0,210) ax.legend(loc='upper right') ax.grid(which='minor') file_name_key = '-'.join(cn_list) file_name = ("Apple Maps Mobility Trends Reports " + file_name_key + ".png").replace(' ', '-') fig.savefig(file_name, bbox_inches='tight', pad_inches=0)