plot_pizza: Creates a pizza plot with no preset groups or colors. The...

View source: R/plot_pizza.R

plot_pizzaR Documentation

Creates a pizza plot with no preset groups or colors. The data frame must have the following columns named exactly as shown: player, statistic, value, percentile, category, and color. The plot will follow the order of the data frame.

Description

Creates a pizza plot with no preset groups or colors. The data frame must have the following columns named exactly as shown: player, statistic, value, percentile, category, and color. The plot will follow the order of the data frame.

Usage

plot_pizza(
  df,
  title,
  subtitle = "",
  caption = "",
  pos_group = "",
  theme_color,
  logo_path = "",
  title_loc = "left"
)

Arguments

df

A data frame with six columns: player, statistic, value, percentile, category and color. percentile is expected to be a number between 0 and 99.

title

Text to appear as the title

subtitle

Text to appear in the subtile.

caption

Text to appear in the caption (bottom)

pos_group

The position group to use for the average line text. Not required.

theme_color

The theme color to use: light or dark. Default is light.

logo_path

The path to the logo to use. Not required.

title_loc

The location of the title: left, center, or right. Default is left.

Value

A ggplot object

Examples

## Not run: 
scaled_data <- data.frame(player = rep("Alexia Putellas", 12),
                          statistic = c("Non-Penalty Goals", "Assists", "Shot-Creating Actions",
                          "Pass Completion Perc", "Progressive Passes", "Progressive Carries",
                          "Tackles", "Interceptions", "Aerials Won",
                          "Fouls Drawn","Fouls Committed", "Offsides"),
                          value = c(.69, 0.1, 6.2, 80, 8.1, 2.0, 0.8, 0.4, 0.8, 0.8, 0.7, 0.7),
                          percentile = c(85, 48, 99, 99, 99, 70, 42, 85, 21, 42, 73, 61),
                          category = rep(c("Attack", "Possession", "Defending", "Misc"), each = 3),
                          color = rep(c("#008000", "#0000FF", "#FF0000", "#FFA500") ,each = 3))

p <- plot_radar_man(scaled_data,
                    title = scaled_data$player[1],
                    subtitle = paste("All Matches for 2023 | Compared to FWDs","All Data per 90", sep = "\n"),
                    caption = "Data: FBref.com | By: Sean Steele",
                    pos_group = "FW/AM",
                    theme_color = "light")
p

## End(Not run)

stxlen/soccr documentation built on Feb. 17, 2025, 1:23 a.m.