# Don't forget to load the ggplot2 package library(ggplot2)
2024
# Don't forget to load the ggplot2 package library(ggplot2)
aes
function# The aes function is used to map variables to aesthetics ggplot(mpg, aes(x = displ, y = hwy)) + geom_point()
x
and y
for the x and y axescolor
for the color of the pointsshape
for the shape of the pointssize
for the size of the pointsalpha
for the transparency of the pointslinetype
for the type of linefill
for the fill color of the pointsggplot(mpg, aes(x = displ, y = hwy, color = class)) + geom_point()
ggplot(mpg, aes(x = displ, y = hwy, shape = class)) + geom_point()
ggplot(mpg, aes(x = displ, y = hwy, size = class)) + geom_point()
ggplot(mpg, aes(x = displ, y = hwy, alpha = class)) + geom_point()
ggplot(mpg, aes(x = displ, y = hwy, linetype = class)) + geom_point()
ggplot(mpg, aes(x = displ, y = hwy, fill = class)) + geom_point()
Make a ggplot
encoding the class
variable in the mpg
dataset using the fill
, shape
, and color
aesthetics.
ggplot(mpg, aes(x = displ, y = hwy, fill=class, shape=class, color=class)) + geom_point()