Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created April 17, 2019 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutannihilation/0b3a2b30ece153902c068fba5bf738f2 to your computer and use it in GitHub Desktop.
Save yutannihilation/0b3a2b30ece153902c068fba5bf738f2 to your computer and use it in GitHub Desktop.
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