r - Using aesthetics with multiple layers in ggplot -


i new ggplot. trying understand how use ggplot. reading wickham's book , still trying wrap head around how use aes() function.

what's difference between these 2 implementations of aes():

library(ggplot2)  ggplot(mpg, aes(displ, hwy, colour = class)) +   geom_point() +   geom_smooth(method = "lm", se = false) +   theme(legend.position = "none") 

and

ggplot(mpg, aes(displ, hwy)) +   geom_point(aes(colour = class)) +   geom_smooth(method = "lm", se = false) +   theme(legend.position = "none") 

both of them print different graphs. help? stuck.

in first 1 mapping aesthetics globally, ggplot try map these aesthetics other geom_xyz() layers.

while in latter case, mapping aesethics specific ggplot layer (in case geom_point())


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -