import pandas as pd
import pickle
import matplotlib.pyplot as plt
import seaborn as sns
import osm
data_input = open('../total0221.pkl','rb')
read_data = pickle.load(data_input)
data_input.close()
df = pd.read_csv('cleansed_timetable.csv')
ttdf = osm.TimetableDf(df)
# 获取 国家-车站-频次信息
country_stations_freq=ttdf.get_country_stations_freq()
#### 1. 国家-车站总数
data={'Country':[],'Number of stations':[]}
c_t = []
for c in country_stations_freq:
c_t.append([c,len(country_stations_freq[c])])
c_t=sorted(c_t,key=lambda x:x[1],reverse=True)
data={'Country':[],'Number of stations':[]}
for c in c_t:
data['Country'].append(c[0])
data['Number of stations'].append(c[1])
DATA = pd.DataFrame(data = data)
sns.set(style="darkgrid")
(fx,fy)=(3000,2400)
my_dpi=300
fig=plt.figure(figsize=(fx/my_dpi, fy/my_dpi), dpi=my_dpi)
ax = fig.add_subplot(1,1,1)
ax = sns.barplot(y="Country",
x='Number of stations',
#hue="company",
data=DATA)
ax.set_ylabel("Country")
plt.savefig('../figures/barplot0221', bbox_inches='tight',pad_inches = 0)
plt.close(fig)
plt.clf()
网友评论