Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save infotroph/24fad7b8c3a11740e2e1bd724da26520 to your computer and use it in GitHub Desktop.

Select an option

Save infotroph/24fad7b8c3a11740e2e1bd724da26520 to your computer and use it in GitHub Desktop.
# Have:
# A scatterplot with points grouped by binning a continuous variable.
(ggplot(mtcars, aes(wt, mpg, color=carb>2))
+geom_point()
+geom_smooth(aes(color=carb>2), method="lm"))
# Also have:
# A scatterplot with the smoothers grouped but points colored continuously
(ggplot(mtcars, aes(wt, mpg, color=carb))
+geom_point()
+geom_smooth(aes(lty=carb>2), method="lm"))
# Want:
# Smoothers coded by one discrete color scale, points coded by a second continuous color scale
(ggplot(mtcars, aes(wt, mpg, color=carb))
+geom_point()
+geom_smooth(aes(color=carb>2), method="lm"))
# Error: Discrete value supplied to continuous scale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment