Closed duttashi closed 6 years ago
Note: This question was originally asked on SO
Solution:
a) Create a variable colors
and assign it color values like, top_bot_5_both <- top_bot_5_both %>% mutate(color = ifelse(Party == "Democratic", "#1A80C4", "#CC3D3D"))
b)
ggplot(top_bot_5_both, aes(x = name, y = score, fill = Party)) +
geom_col(size = 1, color = "black") +
coord_flip() +
geom_vline(xintercept = 10.5, size = 1.5, linetype = "twodash") +
scale_fill_manual(values = c("Democratic" = "#1A80C4", "Republican" = "#CC3D3D")) +
theme(axis.text = element_text(size = 12),
axis.text.y = element_text(color = colors),
axis.title = element_text(size = 14),
legend.position = "bottom",
legend.title = element_blank())
See the plot
How to make a column graph that has the y-axis text mirror the fill color in the graph itself?