Example #1
0
    def multi_game_shot_chart(self, games, **kwargs):

        made_shots = []
        missed_shots = []

        start_date = None
        end_date = None
        for game in games:
            if game.player_in_game(self):
                if not start_date:
                    start_date = game.date
                end_date = game.date
                made_shots = np.concatenate((made_shots, self.made_shots(game)))
                missed_shots = np.concatenate((missed_shots, self.missed_shots(game)))

        if 'plot_type' in kwargs:
            plot_type = kwargs['plot_type']
        else:
            plot_type = 'hexbin'
        if 'hex_size' in kwargs:
            hex_size = kwargs['hex_size']
        else:
            hex_size = 1
        if 'overplot_shots' in kwargs:
            overplot_shots = kwargs['overplot_shots']
        else:
            overplot_shots = False

        first_name, last_name = self.first_name, self.last_name

        create_shot_chart(made_shots, missed_shots,
                          'plots/players/{}_{}_shots_from_{}_to_{}.pdf'.format(first_name, last_name, start_date, end_date),
                          '{} {} from {} to {}'.format(first_name, last_name, start_date, end_date),
                          plot_type=plot_type, hex_size=hex_size, overplot_shots=overplot_shots)
Example #2
0
    def shot_chart(self, game, **kwargs):

        made_shots = self.made_shots(game)
        missed_shots = self.missed_shots(game)

        if 'plot_type' in kwargs:
            plot_type = kwargs['plot_type']
        else:
            plot_type = 'hexbin'
        if 'hex_size' in kwargs:
            hex_size = kwargs['hex_size']
        else:
            hex_size = 1
        if 'overplot_shots' in kwargs:
            overplot_shots = kwargs['overplot_shots']
        else:
            overplot_shots = False

        gd = game.date
        team1_name = game.home_team.nickname
        team2_name = game.away_team.nickname
        first_name, last_name = self.first_name, self.last_name

        create_shot_chart(made_shots,
                          missed_shots,
                          'plots/players/{}_{}_shots_{}_{}_vs_{}.pdf'.format(
                              first_name, last_name, gd, team1_name,
                              team2_name),
                          '{} {} on {} - {} vs {}'.format(
                              first_name, last_name, gd, team1_name,
                              team2_name),
                          plot_type=plot_type,
                          hex_size=hex_size,
                          overplot_shots=overplot_shots)
Example #3
0
    def shot_chart(self, game, **kwargs):

        made_shots = self.made_shots(game)
        missed_shots = self.missed_shots(game)

        if 'plot_type' in kwargs:
            plot_type = kwargs['plot_type']
        else:
            plot_type = 'hexbin'
        if 'hex_size' in kwargs:
            hex_size = kwargs['hex_size']
        else:
            hex_size = 1
        if 'overplot_shots' in kwargs:
            overplot_shots = kwargs['overplot_shots']
        else:
            overplot_shots = False

        gd = game.date
        team1_name = game.home_team.nickname
        team2_name = game.away_team.nickname
        first_name, last_name = self.first_name, self.last_name

        create_shot_chart(made_shots, missed_shots,
                          'plots/players/{}_{}_shots_{}_{}_vs_{}.pdf'.format(first_name, last_name, gd, team1_name, team2_name),
                          '{} {} on {} - {} vs {}'.format(first_name, last_name, gd, team1_name, team2_name),
                          plot_type=plot_type, hex_size=hex_size, overplot_shots=overplot_shots)
Example #4
0
    def multi_game_shot_chart(self, games, **kwargs):

        made_shots = []
        missed_shots = []

        start_date = None
        end_date = None
        for game in games:
            if game.player_in_game(self):
                if not start_date:
                    start_date = game.date
                end_date = game.date
                made_shots = np.concatenate((made_shots, self.made_shots(game)))
                missed_shots = np.concatenate((missed_shots, self.missed_shots(game)))

        if 'plot_type' in kwargs:
            plot_type = kwargs['plot_type']
        else:
            plot_type = 'hexbin'
        if 'hex_size' in kwargs:
            hex_size = kwargs['hex_size']
        else:
            hex_size = 1
        if 'overplot_shots' in kwargs:
            overplot_shots = kwargs['overplot_shots']
        else:
            overplot_shots = False

        first_name, last_name = self.first_name, self.last_name

        create_shot_chart(made_shots, missed_shots,
                          'plots/players/{}_{}_shots_from_{}_to_{}.pdf'.format(first_name, last_name, start_date, end_date),
                          '{} {} from {} to {}'.format(first_name, last_name, start_date, end_date),
                          plot_type=plot_type, hex_size=hex_size, overplot_shots=overplot_shots)