Chapter 12: Exercises - Fundamentals of Sports Data Visualization
Overview
These exercises progress from basic chart creation to sophisticated visualization design for sports analytics. Each level builds on previous skills, culminating in creating professional-quality visualizations suitable for front office presentations.
Level 1: Conceptual Understanding
Exercise 1.1: Pre-Attentive Attributes
For each visualization goal below, identify the most appropriate pre-attentive attribute(s):
a) Highlighting a single player among 50 in a scatter plot b) Showing which teams improved vs. declined from last season c) Representing four different conferences in a comparison chart d) Indicating the magnitude of EPA across plays e) Showing movement patterns from season start to end
Questions: 1. Why is position generally more accurate than color intensity for encoding values? 2. What happens to our ability to perceive differences when we use multiple pre-attentive attributes simultaneously? 3. Name a situation where color hue would be preferable to position for encoding data.
Exercise 1.2: Chart Type Selection
For each scenario, select the most appropriate chart type and justify your choice:
a) Comparing passing efficiency across 14 SEC teams b) Showing how a team's win probability changed throughout a game c) Displaying the relationship between recruiting rankings and win percentage d) Presenting the composition of a team's offensive play types (run inside, run outside, short pass, deep pass) e) Comparing individual player performances across multiple metrics simultaneously
Exercise 1.3: Audience Analysis
A coaching staff requests visualizations for their upcoming game preparation. Different stakeholders need different views:
- Head Coach: Needs quick insights during film sessions
- Offensive Coordinator: Needs detailed play-type breakdowns
- Quality Control Staff: Needs granular situational data
For each audience: a) What level of detail is appropriate? b) What should be emphasized vs. de-emphasized? c) What interaction capabilities would be helpful? d) What is the appropriate time frame for viewing?
Exercise 1.4: Color Accessibility
Evaluate the following color scheme for a dashboard showing team performance: - Green for positive EPA - Red for negative EPA - Yellow for neutral - Blue for league average
Questions: 1. What problems might colorblind users experience? 2. Propose an alternative scheme that maintains meaning while improving accessibility 3. What additional visual encoding could supplement color?
Exercise 1.5: Cognitive Load Assessment
Review a cluttered sports visualization (imagine or find one) and identify:
a) Elements that contribute unnecessary cognitive load b) Information that could be removed without losing meaning c) Ways to group related information using Gestalt principles d) Opportunities to use progressive disclosure
Level 2: Basic Visualizations
Exercise 2.1: Team Comparison Bar Chart
Create a horizontal bar chart comparing the following EPA/play data:
team_data = {
'Georgia': 0.215,
'Michigan': 0.198,
'Ohio State': 0.187,
'Alabama': 0.175,
'Texas': 0.168,
'Oregon': 0.155,
'Penn State': 0.142,
'Florida State': 0.138,
'Washington': 0.125,
'LSU': 0.118
}
Requirements: 1. Sort teams by EPA value (highest to lowest) 2. Use a single color with appropriate saturation 3. Add value labels at the end of each bar 4. Include a vertical line at 0.150 representing "elite" threshold 5. Add a descriptive title and axis labels 6. Remove unnecessary chart junk (gridlines, borders, etc.)
Exercise 2.2: Time Series Line Chart
Create a line chart showing weekly offensive EPA for three teams:
weeks = list(range(1, 13))
team_epa = {
'Team A': [0.12, 0.15, 0.18, 0.22, 0.19, 0.25, 0.28, 0.24, 0.31, 0.29, 0.33, 0.35],
'Team B': [0.20, 0.18, 0.22, 0.19, 0.15, 0.12, 0.10, 0.08, 0.11, 0.09, 0.07, 0.05],
'Team C': [0.14, 0.16, 0.15, 0.17, 0.16, 0.18, 0.17, 0.19, 0.18, 0.20, 0.19, 0.21]
}
Requirements: 1. Use distinct colors for each team 2. Add markers at each data point 3. Include a legend positioned appropriately 4. Add annotations for significant changes (Team B's decline, Team A's improvement) 5. Include subtle gridlines for readability 6. Shade regions to indicate "above average" (>0.15) and "below average"
Exercise 2.3: Scatter Plot with Context
Create a scatter plot showing the relationship between recruiting ranking and win percentage:
import numpy as np
np.random.seed(42)
teams = 130
recruiting_rank = np.random.randint(1, 131, teams)
# Win pct correlated with recruiting but with noise
win_pct = np.clip(0.7 - (recruiting_rank / 200) + np.random.normal(0, 0.15, teams), 0.1, 0.95)
conference = np.random.choice(['Power 5', 'Group of 5'], teams, p=[0.5, 0.5])
Requirements: 1. Color-code points by conference 2. Add a trend line showing the relationship 3. Label outliers (teams significantly above/below trend) 4. Include appropriate axis labels with units 5. Add a reference line at 0.500 win percentage 6. Use appropriate marker sizes and transparency for overlapping points
Exercise 2.4: Distribution Visualization
Create a visualization showing the distribution of QB passing EPA/attempt:
import numpy as np
np.random.seed(42)
# Generate EPA/attempt data for 100 qualified QBs
qb_epa = np.random.normal(0.08, 0.12, 100)
Requirements: 1. Create both a histogram and a kernel density estimate 2. Mark the mean and median 3. Shade regions for "below average" (<0) and "elite" (>0.20) 4. Add a rug plot showing individual observations 5. Include descriptive statistics in a text annotation
Exercise 2.5: Small Multiples
Create a small multiples display showing offensive EPA by quarter for four teams:
quarter_data = {
'Team A': {'Q1': 0.22, 'Q2': 0.18, 'Q3': 0.15, 'Q4': 0.25},
'Team B': {'Q1': 0.10, 'Q2': 0.15, 'Q3': 0.20, 'Q4': 0.22},
'Team C': {'Q1': 0.18, 'Q2': 0.16, 'Q3': 0.08, 'Q4': 0.05},
'Team D': {'Q1': 0.14, 'Q2': 0.14, 'Q3': 0.15, 'Q4': 0.13}
}
Requirements: 1. Use consistent scales across all panels 2. Label each panel with team name 3. Use color to encode performance level 4. Add a descriptive title for the overall figure 5. Include a shared legend or color bar
Level 3: Advanced Chart Types
Exercise 3.1: Radar Chart for Player Comparison
Create a radar chart comparing three running backs across multiple metrics:
metrics = ['Rush EPA', 'Success Rate', 'Yards After Contact',
'Explosive Rate', 'Fumble Rate (inv)', 'Pass Block Grade']
players = {
'Player A': [0.85, 0.78, 0.92, 0.88, 0.95, 0.72],
'Player B': [0.72, 0.85, 0.78, 0.75, 0.88, 0.90],
'Player C': [0.90, 0.70, 0.85, 0.95, 0.80, 0.65]
}
# Values are percentiles (0-1 scale)
Requirements: 1. Normalize all metrics to a 0-1 scale 2. Use distinct colors with transparency for overlap visibility 3. Include axis labels for each metric 4. Add a legend identifying each player 5. Include gridlines at 0.25, 0.50, 0.75, and 1.00 6. Annotate the chart with a key insight
Exercise 3.2: Heatmap for Situational Analysis
Create a heatmap showing EPA by down and distance:
import numpy as np
downs = [1, 2, 3]
distances = ['1-3', '4-6', '7-10', '11-15', '16+']
# EPA values (rows=downs, cols=distances)
epa_matrix = np.array([
[0.25, 0.18, 0.12, 0.08, 0.02], # 1st down
[0.30, 0.20, 0.10, -0.05, -0.15], # 2nd down
[0.45, 0.25, 0.05, -0.20, -0.35] # 3rd down
])
Requirements: 1. Use a diverging color scheme centered at 0 2. Add cell annotations with EPA values 3. Include clear axis labels (Down, Distance to Go) 4. Add a color bar with appropriate label 5. Ensure colorblind accessibility 6. Add a title explaining what the visualization shows
Exercise 3.3: Bump Chart for Rankings
Create a bump chart showing conference ranking changes over 5 weeks:
weeks = [1, 2, 3, 4, 5]
conference_ranks = {
'SEC': [1, 1, 1, 2, 1],
'Big Ten': [2, 2, 2, 1, 2],
'Big 12': [3, 4, 3, 3, 3],
'ACC': [4, 3, 4, 4, 5],
'Pac-12': [5, 5, 5, 5, 4]
}
Requirements: 1. Use line thickness to represent importance/size 2. Color-code each conference 3. Add labels at start and end points 4. Highlight rank changes with annotations 5. Invert y-axis so rank 1 is at top 6. Use appropriate spacing and styling
Exercise 3.4: Waterfall Chart for Score Contribution
Create a waterfall chart showing how a team's EPA accumulated through a game:
drives = ['Drive 1', 'Drive 2', 'Drive 3', 'Drive 4', 'Drive 5',
'Drive 6', 'Drive 7', 'Drive 8', 'Drive 9', 'Drive 10']
epa_values = [2.5, -1.2, 4.8, 1.5, -3.2, 6.2, -0.8, 3.5, 2.1, -1.5]
Requirements: 1. Show running total progression 2. Color positive and negative contributions differently 3. Include connecting lines between bars 4. Add a final "Total" bar 5. Include value labels on each bar 6. Add a baseline at 0
Exercise 3.5: Dumbbell Chart for Before/After
Create a dumbbell chart showing team improvement from Week 1 to Week 12:
teams = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
week_1_epa = [0.08, 0.15, 0.22, 0.05, 0.18]
week_12_epa = [0.25, 0.12, 0.28, 0.22, 0.10]
Requirements: 1. Show Week 1 and Week 12 values as connected points 2. Color connections by improvement vs. decline 3. Sort teams by magnitude of change 4. Add value labels at both endpoints 5. Include a reference at 0.15 (average) 6. Add a legend explaining the encoding
Level 4: Dashboard Design
Exercise 4.1: Single-Page Team Dashboard
Design and implement a single-page dashboard for a team's offensive performance:
Data provided:
team_stats = {
'overall': {'epa_play': 0.18, 'success_rate': 0.46, 'explosive_rate': 0.12},
'passing': {'epa_play': 0.22, 'success_rate': 0.48, 'attempts': 412},
'rushing': {'epa_play': 0.10, 'success_rate': 0.42, 'attempts': 385},
'by_down': {1: 0.15, 2: 0.12, 3: 0.08},
'by_quarter': {'Q1': 0.20, 'Q2': 0.18, 'Q3': 0.15, 'Q4': 0.22},
'weekly_trend': [0.12, 0.15, 0.18, 0.16, 0.20, 0.22, 0.19, 0.25, 0.18, 0.22, 0.20, 0.24]
}
Requirements: 1. Create a 2x3 grid layout 2. Include: KPI cards, trend line, down comparison, play type breakdown, quarterly performance, league comparison 3. Use consistent color scheme throughout 4. Establish clear visual hierarchy 5. Include appropriate titles and labels 6. Ensure the dashboard tells a coherent story
Exercise 4.2: Comparative Dashboard
Create a side-by-side team comparison dashboard:
team_a = {
'name': 'Team A',
'metrics': {
'EPA/Play': 0.22, 'Success Rate': 0.48,
'Explosive Rate': 0.14, 'Turnover Rate': 0.08,
'Red Zone TD%': 0.72, '3rd Down Conv': 0.44
},
'rank': {'offense': 5, 'defense': 12, 'special': 8}
}
team_b = {
'name': 'Team B',
'metrics': {
'EPA/Play': 0.15, 'Success Rate': 0.44,
'Explosive Rate': 0.11, 'Turnover Rate': 0.12,
'Red Zone TD%': 0.65, '3rd Down Conv': 0.38
},
'rank': {'offense': 25, 'defense': 8, 'special': 15}
}
Requirements: 1. Show head-to-head metric comparisons 2. Highlight advantages for each team 3. Include overall "winner" indicators per category 4. Use color to indicate which team leads each metric 5. Add context (league average) where appropriate 6. Create a summary "matchup advantage" visualization
Exercise 4.3: Interactive Filtering Design
Design (wireframe/mockup) an interactive dashboard that allows users to:
- Filter by: Team, Conference, Time Period, Play Type
- Drill down from conference → team → player
- Compare any two selected entities
- Toggle between offensive and defensive views
For each interaction: a) Describe the UI control (dropdown, slider, toggle, etc.) b) Explain what changes when the filter is applied c) Describe any linked behaviors between visualizations
Exercise 4.4: Mobile-Responsive Design
Adapt the team dashboard from Exercise 4.1 for mobile display:
Requirements: 1. Prioritize information for small screens 2. Stack visualizations vertically 3. Simplify charts for thumb navigation 4. Maintain readability at smaller sizes 5. Identify which elements can be hidden behind expandable sections 6. Specify minimum touch target sizes
Level 5: Professional Projects
Exercise 5.1: Recruiting Presentation Package
Create a complete visualization package for a recruiting presentation to a top high school prospect:
Content to visualize: - School's offensive/defensive rankings over 5 years - Player development (freshman to senior improvement) - NFL draft success - Playing time for freshmen - Academic support and graduation rates - Facilities comparisons
Requirements: 1. Create 5-7 professional visualizations 2. Design for projection in a recruit's living room 3. Emphasize storytelling over data density 4. Use school colors appropriately 5. Include comparative context 6. Make emotional connection while maintaining accuracy
Exercise 5.2: Broadcast Graphics Package
Design a set of graphics suitable for game broadcast:
Graphics needed: 1. Pre-game team comparison graphic 2. In-game situation display (down, distance, win probability) 3. Player spotlight with key stats 4. Drive summary visualization 5. Half-time statistical comparison 6. Post-game summary graphic
Requirements: 1. Design for 1920x1080 HD broadcast 2. Ensure readability at distance 3. Use animation concepts (describe transitions) 4. Keep graphics on screen for 5-8 seconds 5. Include school/conference branding guidelines 6. Ensure accessibility for colorblind viewers
Exercise 5.3: Analytics Department Style Guide
Create a comprehensive style guide for a college football program's analytics department:
Include: 1. Color palette (primary, secondary, accent, semantic colors) 2. Typography specifications (fonts, sizes, hierarchy) 3. Chart templates for common visualizations 4. Logo usage and placement guidelines 5. Do's and Don'ts with examples 6. Accessibility requirements 7. File format and resolution standards 8. Naming conventions
Create at least 3 example visualizations demonstrating the style guide.
Exercise 5.4: Season Review Report
Create a complete visual report summarizing a team's season:
Sections to include: 1. Executive summary (single page of KPIs) 2. Offensive performance deep dive (3-4 pages) 3. Defensive performance analysis (3-4 pages) 4. Special teams review (1-2 pages) 5. Player highlights and development 6. Areas for improvement 7. Recruiting implications
Requirements: 1. Design for print (letter size, 300 DPI) 2. Create consistent page layouts 3. Balance text and visualization 4. Include data tables where appropriate 5. Add callout boxes for key insights 6. Design cover page and table of contents
Exercise 5.5: Real-Time Dashboard Prototype
Design and prototype a real-time game monitoring dashboard for coaching staff:
Features to include: 1. Live win probability display 2. Play-by-play EPA tracker 3. Situational tendency analysis (updating) 4. Opponent adjustment indicators 5. Timeout and clock management aids 6. Key matchup tracking
Requirements: 1. Design for tablet display (iPad Pro size) 2. Update frequency: after each play 3. Maximum glance time: 3 seconds per visualization 4. Include alert system for key situations 5. Allow filtering by unit (offense/defense/special teams) 6. Design for outdoor visibility (bright sunlight conditions)
Submission Guidelines
For All Exercises:
- Include complete, runnable Python code
- Save visualizations as PNG (300 DPI for print, 150 for screen)
- Include brief written justification for design choices
- Document any accessibility considerations
Code Quality:
- Use functions for reusable components
- Include docstrings and comments
- Follow PEP 8 style guidelines
- Create style configuration files where appropriate
Visualization Checklist:
- [ ] Clear, descriptive title
- [ ] Axis labels with units
- [ ] Legend (if multiple series)
- [ ] Source attribution
- [ ] Colorblind-friendly palette
- [ ] Appropriate data-ink ratio
- [ ] No 3D effects or chart junk
- [ ] Consistent styling
Answer Key Notes
Solutions for these exercises are provided in the code/exercise-solutions.py file. The solutions demonstrate:
- Clean, well-documented code
- Proper use of matplotlib and seaborn
- Accessibility best practices
- Professional styling techniques
For Level 4-5 exercises, solution files include both code and design documentation explaining the rationale behind visualization choices.