Skip to content

Instantly share code, notes, and snippets.

@selva86
Created March 10, 2020 07:07
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 selva86/77c709c86d148562ff26a92283ef1cf3 to your computer and use it in GitHub Desktop.
Save selva86/77c709c86d148562ff26a92283ef1cf3 to your computer and use it in GitHub Desktop.
# Modify the following code to remove the legend title. Then, place the legend in top left position
gg <- ggplot(midwest, aes(x=area, y=poptotal)) + # Define Data
geom_point(aes(col=state, size=popdensity)) + # Add scatterplot
geom_smooth(method="lm", col="firebrick", se=F) + # Add best fit line
coord_cartesian(xlim=c(0, 0.1), ylim=c(0, 250000)) + # Limit X and Y axis
labs(title="Area Vs Population", y="Population", x="Area") # Labels
plot(gg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment