Skip to content

Commit

Permalink
catch invalid team abbrs in theme elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 15, 2024
1 parent 7dfb861 commit 3f2cbd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nflplotR
Title: NFL Logo Plots in 'ggplot2' and 'gt'
Version: 1.4.0.9000
Version: 1.4.0.9001
Authors@R:
person("Sebastian", "Carl", , "[email protected]", role = c("aut", "cre"))
Description: A set of functions to visualize National Football League
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# nflplotR (development version)

* Updated the New York Jets logo (again) to their new secondary logo introduced in the 2024 off-season. This aligns with the logo used across nfl dot com and it has been voted for in a poll. (#68)
* The theme elements `element_nfl_logo()` and `element_nfl_wordmark()` now clean team abbreviations by calling `nflreadr::clean_team_abbrs()` and insert empty grobs for mismatches.

# nflplotR 1.4.0

Expand Down
6 changes: 4 additions & 2 deletions R/theme-elements.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ element_grob.element_nfl_logo <- function(element, label = "", x = NULL, y = NUL
alpha <- alpha %||% element$alpha
colour <- colour %||% rep(element$colour, n)
size <- size %||% element$size
label <- nflreadr::clean_team_abbrs(as.character(label), keep_non_matches = FALSE)

grobs <- lapply(
seq_along(label),
Expand Down Expand Up @@ -225,6 +226,7 @@ element_grob.element_nfl_wordmark <- function(element, label = "", x = NULL, y =
alpha <- alpha %||% element$alpha
colour <- colour %||% rep(element$colour, n)
size <- size %||% element$size
label <- nflreadr::clean_team_abbrs(as.character(label), keep_non_matches = FALSE)

grobs <- lapply(
seq_along(label),
Expand Down Expand Up @@ -297,11 +299,11 @@ axisImageGrob <- function(i, label, alpha, colour, x, y, hjust, vjust,
if(type == "teams") {
team_abbr <- label[i]
image_to_read <- logo_list[[team_abbr]]
if (is.na(team_abbr)) make_null <- TRUE
if (is.na(team_abbr) | is.null(image_to_read)) make_null <- TRUE
} else if(type == "wordmarks") {
team_abbr <- label[i]
image_to_read <- wordmark_list[[team_abbr]]
if (is.na(team_abbr)) make_null <- TRUE
if (is.na(team_abbr) | is.null(image_to_read)) make_null <- TRUE
} else {
gsis <- label[i]
headshot_map <- load_headshots()
Expand Down

0 comments on commit 3f2cbd7

Please sign in to comment.