In [1]:
%matplotlib inline
I've crawled all matches played by challenger tier in NA of SEASON2016 by using 'crawlTierMatches.py'. The S7 season has not started yet, let's just play on this data first.
In [2]:
import pickle
import os
In [3]:
path = os.path.join(os.path.dirname('getMatchList.ipynb'), 'data')
with open(os.path.join(path, 'league_match_history_2016_na.pickle'), 'rb') as f:
match_ids = pickle.load(f)
matches = pickle.load(f)
print(len(matches))
In [4]:
import pandas as pd
In [5]:
matches_stats = pd.DataFrame.from_dict(matches)
matches_stats.head()
Out[5]:
First we need to seperate duo_carry and duo_support.
In [6]:
matches_stats.loc[matches_stats['role'] == 'DUO_CARRY', 'lane'] = 'BOT_ADC'
matches_stats.loc[matches_stats['role'] == 'DUO_SUPPORT', 'lane'] = 'BOT_SUP'
# drop those BOTTOM that are neither DUO_CARRY nor DUO_SUPPORT
matches_stats = matches_stats[matches_stats['lane'] != 'BOTTOM']
matches_stats.head()
Out[6]:
In [7]:
lane_stats = matches_stats.groupby(['lane', 'queue']).size()
lane_stats = lane_stats.unstack()
lane_stats
Out[7]:
In [8]:
ax = lane_stats.plot.bar(stacked=True, legend=False);
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
# Put a legend to the right of the current axis
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=0)
pass
In [9]:
champ_stats = matches_stats.groupby(['lane', 'champion']).size()
champ_stats = champ_stats.unstack()
champ_stats.head()
Out[9]:
In [10]:
from lolcrawler_util import get_champion_name
import matplotlib.pyplot as plt
import numpy as np
In [11]:
f, axarr = plt.subplots(3, 2, figsize=(15,15))
plt_cnt = 0
for lane, row in champ_stats.iterrows():
sorted_row = row.sort_values(ascending=False)
# print(sorted_row[:5].values)
axarr[plt_cnt/2, plt_cnt%2].bar(np.arange(10), sorted_row[:10].values)
axarr[plt_cnt/2, plt_cnt%2].title.set_text(lane)
champion_name = []
for c_id in sorted_row[:10].index.values:
champion_name.append(get_champion_name(c_id))
axarr[plt_cnt/2, plt_cnt%2].xaxis.set_ticks(np.arange(10))
axarr[plt_cnt/2, plt_cnt%2].set_xticklabels(champion_name, rotation=45)
plt_cnt += 1
f.subplots_adjust(hspace=0.5)
axarr[-1, -1].axis('off')
plt.show()
In [ ]: