The code for this package was heavily based on nbaplotR with minor changes to support Brazilian soccer team badges.
The goal of futebolplotR is to provide functions and geoms that help visualization of Brazilian soccer related analysis. It provides a ggplot2 geom that does the heavy lifting of plotting brazilian soccer badges in high quality, with correct aspect ratio and possible transparency.
The futebolplotR contains badges of the teams participating in the Brasileirão Série A football league from 2003 to the nowadays.
This package can be used with data from brasileirao R package.
You can install the development version of futebolplotR from GitHub with:
if (!require("pak")) install.packages("pak")
pak::pak("brunomioto/futebolplotR")
The key function in the package is geom_futebol_badges()
which will
add Brazilian soccer team badges to a ggplot. Here you can see all the
current available teams (currently 43) to plot.
library(futebolplotR)
library(ggplot2)
team <- valid_team_names()
df <- data.frame(
a = c(rep(1:5, 8),c(1,2,3,4)),
b = sort(c(rep(1:8, 5), c(0,0,0,0)), decreasing = TRUE),
teams = team
)
ggplot(df, aes(x = a, y = b)) +
geom_futebol_badges(aes(team_abbr = teams), width = 0.1) +
geom_label(aes(label = teams,
color = teams,
fill = teams),
nudge_y = -0.35)+
scale_color_futebol(type = "secondary")+
scale_fill_futebol(type = "primary")+
theme_void()+
theme(
plot.margin = margin(15,15,15,15,"pt")
)+
coord_cartesian(clip = "off")