beanumber / beanumber/teamcolors

`scale_color_teams` behavior has changed (?)

Open
#28 6 comments 0 reactions 1 assignee Claimed by @beanumber View on GitHub
Dominant language
R
Stars
50
Forks
14
PR merge metrics
No merged PRs in 30d

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
```
![image](https://user-images.githubusercontent.com/48807452/138618227-ee7fed6f-e2ca-4e16-994d-474308de1c68.png)

```
# What worked as recently as May 2021, but now does not
p + scale_color_teams(1, labels = toy_data$team)
```
![image](https://user-images.githubusercontent.com/48807452/138618241-62bb5302-3f4c-4434-ba82-f1f014c5058a.png)

```
# How the preceding plot was intended to look
p + scale_color_discrete(labels = toy_data$team, type = league_pal(lg = "nba"))
```
![image](https://user-images.githubusercontent.com/48807452/138618253-f2fb3a05-53e3-4a19-8f55-eb27380e0d62.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.