-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
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
# What worked as recently as May 2021, but now does not
p + scale_color_teams(1, labels = toy_data$team)
# How the preceding plot was intended to look
p + scale_color_discrete(labels = toy_data$team, type = league_pal(lg = "nba"))
Metadata
Metadata
Assignees
Labels
No labels


