Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl))) +
geom_bar(aes(fill = factor(cyl)))
p + scale_x_discrete(limits = c("4", "8"))
p + scale_fill_discrete(limits = c("4", "8"))
cols <- c("8" = "red", "4" = "blue", "6" = "darkgreen", "10" = "orange")
p + scale_fill_manual(values = cols, limits = c("4", "8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.