from fplplayers import Data from games import Games d = Data('data.json') g = Games('E0.csv') #all_teams = list(d.all_teams()) all_teams = ['Arsenal', 'Chelsea', 'Liverpool', 'Man City']#, 'Man Utd', 'Everton', 'Tottenham',] temp_points_progressions = [g.of_team(t).points_progression_for(t) for t in all_teams] points_progressions = [] for p in temp_points_progressions: points_progressions.append([0,] + p) import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() ax.set_ylabel('Points') ax.set_xlabel('Gameweek') ax.set_title('Points progression') ax.set_xticks(np.arange(38)+1) ax.set_yticks(np.arange(0,114,3)) #ax.legend TODO lines = [] for team, points in zip(all_teams, points_progressions): lines.append(ax.plot(np.arange(len(points)), points)) ax.legend( tuple([line[0] for line in lines]), tuple(all_teams), loc=4)
predictedpoints[team] = 0 for f in fixtures: if f.playedat == "A": for gm in g.of_team_at_home(team): if f.opponent == gm.awayteam: predictedpoints[team] += gm.homepoints # print team+ ' scored '+str(gm.homepoints)+' against '+gm.awayteam.name break else: for gm in g.of_team_at_away(team): if f.opponent == gm.hometeam: predictedpoints[team] += gm.awaypoints # print team+ ' scored '+str(gm.awaypoints)+' against '+gm.hometeam.name break finalpoints.append((team, predictedpoints[team] + points(g.of_team(team), team), points(g.of_team(team), team))) finalpoints.sort(key=lambda x: x[1], reverse=True) tmp = finalpoints[1] finalpoints[1] = finalpoints[0] finalpoints[0] = tmp # Now for the plotting fun import numpy as np import matplotlib.pyplot as plt N = 20 ind = np.arange(N) width = 0.35