def shots4time(player='Noah', team='CHI', 
               s_date='20091001', f_date='20151231', path='D:\Gal\Work\Results'):
    ''' '''
    actions_1, played_games_1 = actions_raster(players=[player], team=team,
                                               s_date=s_date, f_date=f_date, path=path, action=c.Shot)
    actions_2, played_games_2 = time_raster(player, team, s_date, f_date, path)
    actions_3, played_games_3 = actions_raster(players=[player], team=team, 
                                               s_date=s_date, f_date=f_date, path=path, action=c.FreeThrow)

    plt.hold(1)
    # plt.title(player+','+team)
    # plt.plot(actions_1, played_games_1, 'b.')
    # plt.plot(actions_3, played_games_3, 'm.')

    plt.figure(1)
    plt.plot(actions_histogram(actions_1), 'b')
    plt.plot(actions_histogram(actions_2), 'r')
    plt.plot(actions_histogram(actions_3), 'm')

    plt.figure(2)
    plt.title(player+','+team)
    plt.figtext(0, 0.5, 'blue - shots \n'+'red - presentce on court\n'+'magenta - freethrows')
    plt.plot(tf.normalize(tf.movingAverage(actions_histogram(actions_1), 3)), 'b')
    plt.plot(tf.normalize(tf.movingAverage(actions_histogram(actions_2), 3)), 'r')
    plt.plot(tf.normalize(tf.movingAverage(actions_histogram(actions_3), 3)), 'm')
    plt.xlabel('Time (in half minutes)')
    plt.ylabel('Points')
    plt.grid(axis='x')
    plt.xticks(np.arange(1, 5)*c.Q_LEN/30)
    plt.show()
Beispiel #2
0
ah_2 = rf.actions_histogram(rf.get_timing_histogram(b), 1)
ah_3 = rf.actions_histogram(rf.get_timing_histogram(c), 1)

shot_percentage = []
for i in xrange(np.min([len(ah_3), len(ah_2)])):
    shot_percentage.append(float(ah_3[i]/ah_2[i])*100)


mpl.plot(ah_1, 'r')
mpl.plot(ah_2, 'b')
mpl.plot(ah_3, 'g')
mpl.xlabel('Time (in seconds)')
mpl.xlim([
mpl.grid(axis='x')


mpl.figure(2)
mpl.plot(tf.normalize(ah_1), 'r')
mpl.plot(tf.normalize(ah_2), 'b')
mpl.plot(tf.normalize(ah_3), 'g')
mpl.xlabel('Time (in seconds)')
mpl.xlim([0, 25])
mpl.grid(axis='x')

mpl.figure(3)
mpl.plot(shot_percentage)
mpl.xlabel('Time (in seconds)')
mpl.xlim([0, 25])
mpl.grid(axis='x')

mpl.show()