Plotting Football Matches Expected Goals (xG) Stats with 'Understat' Data

Scrapes football match shots data from 'Understat' < https://understat.com/> and visualizes it using interactive plots: - A detailed shot map displaying the location, type, and xG value of shots taken by both teams. - An xG timeline chart showing the cumulative xG for each team over time, annotated with the details of scored goals.


ggfootball

It’s Football not Soccer.

Lifecycle:experimental

Overview

The ggfootball package provides R functions that scrape shots data from understat and visualizes it using interactive plots:

  • A detailed shot map displaying the location, type, and expected goals (xG) value of shots taken by both teams.
  • An xG timeline chart showing the cumulative expected goals for each team over time, annotated with the details of scored goals.

Installation

You can install ggfootball from CRAN with:

install.packages("ggfootball")

Example

library(ggfootball)

# xG chart
xg_chart(match_id = 26631, 
         home_team_color = "red", 
         away_team_color = "grey", 
         competition = "Premier League",
         bg_color = "#FFF1E5",
         plot_bg_color = "#FFF1E5")

# Shot/xG map
xg_map(match_id = 26631, title = "xG Map")

Acknowledgements

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ggfootball")

0.3.0 by Aymen Nasri, 9 months ago


https://aymennasri.github.io/ggfootball/


Report a bug at https://github.com/aymennasri/ggfootball/issues


Browse source code at https://github.com/cran/ggfootball


Authors: Aymen Nasri [aut, cre, cph]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports base64enc, dplyr, gdtools, gfonts, ggiraph, ggplot2, ggsoccer, glue, highcharter, httr, jsonlite, tibble


See at CRAN