Created
October 24, 2016 13:15
-
-
Save yabyzq/3b1358e973026d9cd7bad52dd9072adf to your computer and use it in GitHub Desktop.
basic ggplot
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
# Basic scatter plot of vocabulary (y) against education (x). Use geom_point() | |
ggplot(Vocab, aes(education, vocabulary))+geom_point() | |
# Use geom_jitter() instead of geom_point() | |
ggplot(Vocab, aes(education, vocabulary))+geom_jitter() | |
# Using the above plotting command, set alpha to a very low 0.2 | |
ggplot(Vocab, aes(education, vocabulary))+geom_jitter(alpha = 0.2) | |
# Using the above plotting command, set the shape to 1 | |
ggplot(Vocab, aes(education, vocabulary))+geom_jitter(alpha = 0.2, shape = 1) | |
ggplot(mtcars, aes(mpg, ..density..))+geom_histogram(binwidth = 1) | |
# Rate change | |
ggplot(economics, aes(x = date, y = unemploy/pop)) + | |
geom_line() + | |
geom_rect(data = recess, inherit.aes = FALSE, aes(xmin =begin, xmax=end, ymin = -Inf, ymax =+Inf), fill = "red", alpha = 0.2) | |
ggplot(data= titanic, aes(x=factor(Pclass), fill = factor(Sex)))+geom_bar(position="dodge")+facet_grid(.~Survived) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment