Skip to contents

In conjunction with the ggplot2::theme system, the following element_ functions enable images in non-data components of the plot, e.g. axis text.

  • element_futebol_badge(): draws Brazilian Soccer team badges instead of their abbreviations.

Usage

element_futebol_badge(
  alpha = NULL,
  colour = NA,
  hjust = NULL,
  vjust = NULL,
  color = NULL,
  size = 0.5
)

Arguments

alpha

The alpha channel, i.e. transparency level, as a numerical value between 0 and 1.

colour, color

The image will be colorized with this color. Use the special character "b/w" to set it to black and white. For more information on valid color names in ggplot2 see https://ggplot2.tidyverse.org/articles/ggplot2-specs.html?q=colour#colour-and-fill.

hjust, vjust

The horizontal and vertical adjustment respectively. Must be a numerical value between 0 and 1.

size

The output grob size in cm (!).

Value

An S3 object of class element.

Details

The elements translate Brazilian Soccer team abbreviations into badge images.

See also

geom_futebol_badges(), and ggpath::element_path() for more information on valid team abbreviations, and other parameters.

Examples

# \donttest{
library(futebolplotR)
library(ggplot2)

team_abbr <- valid_team_names()

df <- data.frame(
  random_value = runif(length(team_abbr), 0, 1),
  team = team_abbr
)

# use badges for x-axis
ggplot(df, aes(x = team, y = random_value)) +
  geom_col(aes(color = team, fill = team), width = 0.5) +
  scale_color_futebol(type = "secondary") +
  scale_fill_futebol(alpha = 0.4) +
  theme_minimal() +
  theme(axis.text.x = element_futebol_badge())


# use badges for y-axis
ggplot(df, aes(y = team, x = random_value)) +
  geom_col(aes(color = team, fill = team), width = 0.5) +
  scale_color_futebol(type = "secondary") +
  scale_fill_futebol(alpha = 0.4) +
  theme_minimal() +
  theme(axis.text.y = element_futebol_badge())


# }