コード例 #1
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_plot_batter(stand, year=2015):
    """
    Visualize the strike zone from the umpire's view for a batter
    Two charts, one for LHP, one for RHP
    Plot the de facto strike zone for the year on each plot """

    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 
    
    fig, (ax1, ax2) = plt.subplots(1,2,figsize=(11.5,6), facecolor='white')

    if stand == 'L':
        ax1.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
        ax2.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
    elif stand == 'S':
        ax1.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey') 
        ax2.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
    else: 
        ax1.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey')
        ax2.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey')

    ax1.set_xlim(-2.5,2.5)
    ax1.set_ylim(0,5)
    ax1.set_ylabel('Strike zone height')
    ax1.set_xlabel('Distance from center of home plate')

    ax2.set_xlim(-2.5,2.5)
    ax2.set_ylim(0, 5)
    ax2.set_ylabel('')
    ax2.set_yticklabels([])
    ax2.set_xlabel('Distance from center of home plate')
    
    plt.tight_layout()
    
    return (fig, ax1,ax2)
コード例 #2
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_layout_pitcher_12(year=2015): 
    """
    Visualize the strike zone from the umpire's view for a pitcher
    Six rows of 2 charts, one for LHB, one for RHB
    Plot the de facto strike zone for the year on each plot """
    
    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 
    
    fig, ((ax1, ax2),(ax3,ax4),(ax5,ax6),
          (ax7,ax8),(ax9,ax10),(ax9,ax10)) = plt.subplots(6,2,figsize=(8,20), facecolor='white')
    # Plot the strike zone on each plot
    for ax in (ax1,ax3,ax5,ax7,ax9,ax11):
        ax.plot(zone_dict['xLs'], zone_dict['yLs'], linewidth=2, color='grey') 
        ax.set_ylabel('Height (feet)')
    for ax in (ax2,ax4,ax6,ax8,ax10,ax12):
        ax.plot(zone_dict['xRs'], zone_dict['yRs'], linewidth=2, color='grey')  
        ax.set_ylabel('')
        ax.set_yticklabels([])
    
    for ax in (ax1, ax2, ax3,ax4,ax5,ax6,ax7,ax8,ax9,ax10,ax11,ax12):
        ax.set_ylim(0,5) 
        ax.set_xlim(-2.5,2.5) 
    for ax in (ax11,ax12):
        ax.set_xlabel('Distance from center of plate (feet)') 
    
    ax1.text(-2.3, 0.2, '@soshbaseball', fontsize=12, alpha=0.8)

    plt.tight_layout()
    return (fig,ax1,ax2, ax3,ax4,ax5,ax6,ax7,ax8,ax9,ax10,ax11,ax12)
コード例 #3
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_layout_pitcher_4(year=2015):
    """
    Visualize the strike zone from the umpire's view for a pitcher
    Four charts, two for LHB, two for RHB 
    Plot the de facto strike zone for the year on each plot """

    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 

    fig, ((ax1, ax2),(ax3,ax4)) = plt.subplots(2,2,figsize=(11.5,12), facecolor='white') 
    
    ax1.set_title('LHB')
    ax2.set_title('RHB')
    for ax in (ax1,ax2,ax3,ax4):
        ax.set_ylim(0, 5.0) 
        ax.set_xlim(-2.5,2.5) 
    for ax in (ax1,ax2):
        ax.set_xticklabels([])
        ax.set_xlabel('')
    for ax in (ax2,ax4):
        ax.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=1, color='dimgrey') 
        ax.set_yticklabels([])
        ax.set_ylabel('')
    for ax in (ax3,ax4):
        ax.set_xlabel("Feet from center of plate", fontsize=14) 
    for ax in (ax1,ax3): 
        ax.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=1, color='dimgrey') 
        ax.set_ylabel('Feet above plate', fontsize=14)
    
    ax1.text(-2.3, 0.2, '@soshbaseball', fontsize=12, alpha=0.8)
    
    plt.tight_layout()
    
    return (fig, ax1, ax2, ax3, ax4) 
コード例 #4
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_plot_batter(stand, year=2016):
    """
    Visualize the strike zone from the umpire's view for a batter
    Two charts, one for LHP, one for RHP
    Plot the de facto strike zone for the year on each plot """

    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 
    
    fig, (ax1, ax2) = plt.subplots(1,2,figsize=(11.5,6), facecolor='white')

    if stand == 'L':
        ax1.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
        ax2.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
    elif stand == 'S':
        ax1.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey') 
        ax2.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=2, color='grey') 
    else: 
        ax1.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey')
        ax2.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=2, color='grey')

    ax1.set_xlim(-2.5,2.5)
    ax1.set_ylim(0,5)
    ax1.set_ylabel('Strike zone height')
    ax1.set_xlabel('Distance from center of home plate')

    ax2.set_xlim(-2.5,2.5)
    ax2.set_ylim(0, 5)
    ax2.set_ylabel('')
    ax2.set_yticklabels([])
    ax2.set_xlabel('Distance from center of home plate')
    
    plt.tight_layout()
    
    return (fig, ax1,ax2)
コード例 #5
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_layout_pitcher_12(year=2016): 
    """
    Visualize the strike zone from the umpire's view for a pitcher
    Six rows of 2 charts, one for LHB, one for RHB
    Plot the de facto strike zone for the year on each plot """
    
    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 
    
    fig, ((ax1, ax2),(ax3,ax4),(ax5,ax6),
          (ax7,ax8),(ax9,ax10),(ax11,ax12)) = plt.subplots(6,2,figsize=(8,20), facecolor='white')
    # Plot the strike zone on each plot
    for ax in (ax1,ax3,ax5,ax7,ax9,ax11):
        ax.plot(zone_dict['xLs'], zone_dict['yLs'], linewidth=2, color='grey') 
        ax.set_ylabel('Height (feet)')
    for ax in (ax2,ax4,ax6,ax8,ax10,ax12):
        ax.plot(zone_dict['xRs'], zone_dict['yRs'], linewidth=2, color='grey')  
        ax.set_ylabel('')
        ax.set_yticklabels([])
    
    for ax in (ax1, ax2, ax3,ax4,ax5,ax6,ax7,ax8,ax9,ax10,ax11,ax12):
        ax.set_ylim(0,5) 
        ax.set_xlim(-2.5,2.5) 
    for ax in (ax11,ax12):
        ax.set_xlabel('Distance from center of plate (feet)') 
    
    ax1.text(-2.3, 0.2, '@soshbaseball', fontsize=12, alpha=0.8)

    plt.tight_layout()
    return (fig,((ax1,ax2),(ax3,ax4),(ax5,ax6),(ax7,ax8),(ax9,ax10),(ax11,ax12)))
コード例 #6
0
ファイル: plotting.py プロジェクト: iayork/Baseball
def basic_layout_pitcher_4(year=2016):
    """
    Visualize the strike zone from the umpire's view for a pitcher
    Four charts, two for LHB, two for RHB 
    Plot the de facto strike zone for the year on each plot """

    from Baseball import strikezone 
    zone_dict = strikezone.get_50pct_zone(year) 

    fig, ((ax1, ax2),(ax3,ax4)) = plt.subplots(2,2,figsize=(11.5,12), facecolor='white') 
    
    ax1.set_title('LHB')
    ax2.set_title('RHB')
    for ax in (ax1,ax2,ax3,ax4):
        ax.set_ylim(0, 5.0) 
        ax.set_xlim(-2.5,2.5) 
    for ax in (ax1,ax2):
        ax.set_xticklabels([])
        ax.set_xlabel('')
    for ax in (ax2,ax4):
        ax.plot(zone_dict['xRs'], zone_dict['yRs'], linestyle='-', linewidth=1, color='dimgrey') 
        ax.set_yticklabels([])
        ax.set_ylabel('')
    for ax in (ax3,ax4):
        ax.set_xlabel("Feet from center of plate", fontsize=14) 
    for ax in (ax1,ax3): 
        ax.plot(zone_dict['xLs'], zone_dict['yLs'], linestyle='-', linewidth=1, color='dimgrey') 
        ax.set_ylabel('Feet above plate', fontsize=14)
    
    ax1.text(-2.3, 0.2, '@soshbaseball', fontsize=12, alpha=0.8)
    
    plt.tight_layout()
    
    return (fig, ((ax1,ax2),(ax3,ax4)))