Skip to contents

These functions enable the use of images in non-data parts of ggplot2 layers, specifically for visualizing elements related to college basketball.

Usage

element_cbb_teams(
  alpha = NULL,
  colour = NA,
  hjust = NULL,
  vjust = NULL,
  color = NULL,
  size = 0.5,
  logo_type = "normal"
)

element_cbb_headshots(
  player_id_column,
  alpha = NULL,
  colour = NA,
  hjust = NULL,
  vjust = NULL,
  color = NULL,
  size = 1.5
)

element_cbb_conferences(
  alpha = NULL,
  colour = NA,
  hjust = NULL,
  vjust = NULL,
  color = NULL,
  size = 0.5,
  logo_type = "normal"
)

# S3 method for class 'element_cbb_teams'
element_grob(
  element,
  label = "",
  x = NULL,
  y = NULL,
  alpha = NULL,
  colour = NULL,
  hjust = 0.5,
  vjust = 0.5,
  size = NULL,
  ...
)

# S3 method for class 'element_cbb_headshots'
element_grob(
  element,
  label = "",
  x = NULL,
  y = NULL,
  alpha = NULL,
  colour = NULL,
  hjust = 0.5,
  vjust = 0.5,
  size = NULL,
  ...
)

# S3 method for class 'element_cbb_conferences'
element_grob(
  element,
  label = "",
  x = NULL,
  y = NULL,
  alpha = NULL,
  colour = NULL,
  hjust = 0.5,
  vjust = 0.5,
  size = NULL,
  ...
)

Arguments

alpha

The transparency level 0-1.

hjust, vjust

Horizontal and vertical adjustment 0-1.

color

(Optional) Colorization for the images; use "b/w" for black and white.

size

Size of the output grob in cm.

logo_type

Type of logo to use ('normal' or 'wordmark' // 'normal' or 'dark'), applicable for element_cbb_conferences and element_cbb_teams.

player_id_column

Column name for player IDs, applicable for element_cbb_headshots.

...

Arguments passed on to ggpath::element_path

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.

angle

The angle of the element as a numerical value between 0° and 360°.

Value

An S3 object of class element appropriate for use in ggplot2 theme settings.

Functions

  • element_cbb_teams(): Replaces text with team logos in ggplot2 themes.

  • element_cbb_conferences(): Replaces text with conference logos in ggplot2 themes.

  • element_cbb_headshots(): Replaces ESPN player IDs with player headshots in ggplot2 themes.