I am trying to color-code points on a geom_point plot to mirror team colors of major league baseball teams (e.g. New York Mets would have a blue-filled point with an orange border). There are similar stack overflow questions whose solutions I have tried to mirror, but with no success.
With the below code, the output applies the first set of colors (from scale_fill_manual) but does not apply the intended border color from scale_color_manual.
What is the proper technique?
#install.packages("Lahman")
library(Lahman)
library(ggthemes)
team_wins <- filter(Teams, yearID > 1990 & yearID != 1994 & yearID !=2020,
franchID %in% c('NYM','WSN','ATL','PHI','FLA'))
graph1 = team_wins %>%
ggplot(aes(x=W, y=attendance)) +
geom_point(alpha = 0.7, stroke = 0, shape = 21, size = 4,
aes(color = factor(franchID),
fill = factor(franchID))) +
theme_fivethirtyeight() +
labs(title = "Wins by NL East Teams over Time",
subtitle = "From 1980 Onward",
x = "# of Wins",
y = "Attendance",
#color = "WSWin",
caption = "Source: Lahman Data") +
theme(axis.title = element_text(),
text = element_text(family = "Trebuchet MS"),
legend.text = element_text(size = 10)) +
theme(legend.title = element_text(hjust = 0.5)) +
scale_x_continuous(breaks = c(seq(55,110,5))) +
scale_y_continuous(breaks = c(seq(0,5000000,1000000))) +
scale_fill_manual(values = c("NYM" = "#002D72",
"ATL" = "#CE1141",
"FLA" = "#00A3E0",
"PHI" = "#E81828",
"WSN" = "#14225A")) +
scale_color_manual(values = c("NYM" = "#FF5910",
"ATL" = "#13274F",
"FLA" = "#EF3340",
"PHI" = "#FFFFFF",
"WSN" = "#AB0003"))
graph1
I tried the code pasted above but the second set of colors are ignored.