Created
July 9, 2016 14:25
-
-
Save aurielfournier/726bd567d36f1f6235b73805e79a4726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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