Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Visualizing Sports Data | Introduction to Sports Analytics
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Sports Analytics

bookVisualizing Sports Data

When you analyze sports data, choosing the right type of visualization is key to uncovering and communicating insights clearly. Different chart types serve different purposes in sports analytics:

  • Bar charts: Compare statistics such as points scored by different teams or players;
  • Line charts: Show trends over time, like a player's scoring progression across matches;
  • Scatter plots: Reveal relationships between two variables, such as minutes played versus points scored;
  • Histograms: Display distributions, for example, the frequency of goals scored in matches;
  • Pie charts: Illustrate proportions, such as the breakdown of play types in a game.

Selecting the appropriate chart helps you highlight the most important aspects of the data, making your analysis clearer and more persuasive.

1234567891011121314151617181920
import pandas as pd import matplotlib.pyplot as plt # Hardcoded DataFrame: Player performance over 5 games data = { "Game": ["Game 1", "Game 2", "Game 3", "Game 4", "Game 5"], "Points": [18, 22, 15, 30, 25] } df = pd.DataFrame(data) # Line plot: Player points over games plt.figure(figsize=(8, 5)) plt.plot(df["Game"], df["Points"], marker="o", linestyle="-", color="b", label="Points Scored") plt.xlabel("Game") plt.ylabel("Points") plt.title("Player Performance Over Time") plt.legend() plt.grid(True) plt.tight_layout() plt.show()
copy

In this code, you create a simple DataFrame to represent a player's points scored across five games. The plt.plot function draws a line chart, where the x-axis shows each game and the y-axis shows points scored. The marker="o" argument adds a dot at each data point, making it easier to see individual performances. Labels for the x-axis and y-axis clarify what each axis represents, and the chart title provides context. The legend explains what the line represents, which is especially helpful when plotting multiple players or statistics. Adding a grid makes it easier to read the values, and tight_layout ensures the labels and title fit neatly.

123456789101112131415161718
import pandas as pd import matplotlib.pyplot as plt # Hardcoded DataFrame: Team statistics comparison data = { "Team": ["Falcons", "Hawks", "Tigers", "Bulls"], "Total Points": [320, 290, 340, 310] } df = pd.DataFrame(data) # Bar chart: Comparing total points by team plt.figure(figsize=(7, 4)) plt.bar(df["Team"], df["Total Points"], color="orange") plt.xlabel("Team") plt.ylabel("Total Points") plt.title("Total Points Scored by Team") plt.tight_layout() plt.show()
copy
question mark

Which chart type is most appropriate for showing the relationship between two continuous variables in sports data, such as assists and points per player?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

bookVisualizing Sports Data

Свайпніть щоб показати меню

When you analyze sports data, choosing the right type of visualization is key to uncovering and communicating insights clearly. Different chart types serve different purposes in sports analytics:

  • Bar charts: Compare statistics such as points scored by different teams or players;
  • Line charts: Show trends over time, like a player's scoring progression across matches;
  • Scatter plots: Reveal relationships between two variables, such as minutes played versus points scored;
  • Histograms: Display distributions, for example, the frequency of goals scored in matches;
  • Pie charts: Illustrate proportions, such as the breakdown of play types in a game.

Selecting the appropriate chart helps you highlight the most important aspects of the data, making your analysis clearer and more persuasive.

1234567891011121314151617181920
import pandas as pd import matplotlib.pyplot as plt # Hardcoded DataFrame: Player performance over 5 games data = { "Game": ["Game 1", "Game 2", "Game 3", "Game 4", "Game 5"], "Points": [18, 22, 15, 30, 25] } df = pd.DataFrame(data) # Line plot: Player points over games plt.figure(figsize=(8, 5)) plt.plot(df["Game"], df["Points"], marker="o", linestyle="-", color="b", label="Points Scored") plt.xlabel("Game") plt.ylabel("Points") plt.title("Player Performance Over Time") plt.legend() plt.grid(True) plt.tight_layout() plt.show()
copy

In this code, you create a simple DataFrame to represent a player's points scored across five games. The plt.plot function draws a line chart, where the x-axis shows each game and the y-axis shows points scored. The marker="o" argument adds a dot at each data point, making it easier to see individual performances. Labels for the x-axis and y-axis clarify what each axis represents, and the chart title provides context. The legend explains what the line represents, which is especially helpful when plotting multiple players or statistics. Adding a grid makes it easier to read the values, and tight_layout ensures the labels and title fit neatly.

123456789101112131415161718
import pandas as pd import matplotlib.pyplot as plt # Hardcoded DataFrame: Team statistics comparison data = { "Team": ["Falcons", "Hawks", "Tigers", "Bulls"], "Total Points": [320, 290, 340, 310] } df = pd.DataFrame(data) # Bar chart: Comparing total points by team plt.figure(figsize=(7, 4)) plt.bar(df["Team"], df["Total Points"], color="orange") plt.xlabel("Team") plt.ylabel("Total Points") plt.title("Total Points Scored by Team") plt.tight_layout() plt.show()
copy
question mark

Which chart type is most appropriate for showing the relationship between two continuous variables in sports data, such as assists and points per player?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
some-alt