Skip to content

Instantly share code, notes, and snippets.

@aurielfournier
Created July 9, 2016 14:25
Show Gist options
  • Save aurielfournier/726bd567d36f1f6235b73805e79a4726 to your computer and use it in GitHub Desktop.
Save aurielfournier/726bd567d36f1f6235b73805e79a4726 to your computer and use it in GitHub Desktop.
# Make Example Graph/Data
a <- data.frame(firstcolumn=seq(1:10), secondcolumn=seq(21:30), thirdcolumn=seq(41:50))
ggplot()+
geom_point(data=a, aes(x=firstcolumn, y=secondcolumn, fill=thirdcolumn))
# One method is to make the column a character instead of a number, than it treats it as discrete
a$thirdcolumn <- as.character(a$thirdcolumn)
ggplot()+
geom_point(data=a, aes(x=firstcolumn, y=secondcolumn, fill=thirdcolumn))
# another option is to use scale_x_discrete (or scale_y_discrete) to tell it to use the fill as discrete
a <- data.frame(firstcolumn=seq(1:10), secondcolumn=seq(21:30), thirdcolumn=seq(41:50))
ggplot()+
geom_point(data=a, aes(x=firstcolumn, y=secondcolumn, fill=thirdcolumn))+
scale_x_discrete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment