Skip to content

scale_color_teams behavior has changed (?) #28

@math-mcshane

Description

@math-mcshane

Hi, this question is either a bug or user error or both, so I wasn't sure whether to post it as an issue. Apologies if it is user error.

As recently as May 2021, I was able to change the labels on my ggplot with scale_color_teams(labels = my_vector_of_labels).

Here's a toy example and my work-around:

library(ggplot2)
library(teamcolors)

#Example data; subset of data from bkref.com
toy_data = data.frame(
  team = rep(c("BOS", "SAS"), times = 3), 
  year = rep(2014:2016, each = 2), 
  Win_Pct = c(0.305, 0.756, 0.488, 0.671, 0.585, 0.817), 
  teamname = rep(c("Boston Celtics", "San Antonio Spurs"), times = 3)
)

# Base plot
# Original plot used 37 seasons of data and all 30 teams, so shrinking the label size was critical
p = ggplot(toy_data, aes(x = year, y = Win_Pct, color = teamname)) + 
  geom_line(size = 5) # line size for clarity of issue
p

image

# What worked as recently as May 2021, but now does not
p + scale_color_teams(1, labels = toy_data$team)

image

# How the preceding plot was intended to look
p + scale_color_discrete(labels = toy_data$team, type = league_pal(lg = "nba"))

image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions