Created
August 16, 2016 22:56
-
-
Save cimentadaj/4d45ec1934db2d4a7ffdd449911eb468 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Let's create a scatterplot with a discrete variable in the X axis | |
p <- ggplot(housing[!is.na(housing$region),], aes(x=State, y=Land.Value, color=Home.Value)) + geom_point(alpha=0.3); p | |
# Note that we set the color to be conditional on a continuous variables(Home.Value) | |
# Here we set the color to be blue when the Home.Value variable is low and red when it's high | |
p + scale_color_gradient(low="blue", high="red", name= "Home Value") | |
# You can do similarly with the scale_color_gradient2, but it has a different default color schem | |
p + scale_color_gradient2(low=muted("red"), mid="white", high=muted("black"), name= "Home Value") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment