细节 Details
This function also standardises aesthetic names by converting color to colour (also in substrings, e.g. point_color to point_colour) and translating old style R names to ggplot names (eg. pch to shape, cex to size).就说标准了绘图通用命名规则,把color换成colour,把pch换成shape,把cex换成size
例子
library(ggplot2)
aes(x = mpg, y = wt)
## Aesthetic mapping:
## * `x` -> `mpg`
## * `y` -> `wt`
aes(mpg, wt)
## Aesthetic mapping:
## * `x` -> `mpg`
## * `y` -> `wt`
You can also map aesthetics to functions of variables。还可以将美学映射到变量函数
aes(x = mpg ^ 2, y = wt / cyl)
## Aesthetic mapping:
## * `x` -> `mpg^2`
## * `y` -> `wt/cyl`
Or to constants。或者映射到常数上
aes(x = 1, colour = "smooth")
## Aesthetic mapping:
## * `x` -> 1
## * `colour` -> "smooth"
美学名称是自动标准化的,如下,所有都一样
aes(col=x)
## Aesthetic mapping:
## * `colour` -> `x`
aes(fg = x)
## Aesthetic mapping:
## * `colour` -> `x`
aes(color = x)
## Aesthetic mapping:
## * `colour` -> `x`
aes(color = x)
## Aesthetic mapping:
## * `colour` -> `x`
注意 ! * aes()被传递给ggplot()或特定图层。提供给ggplot()的美学用作每个图层的默认值。*
ggplot(mpg, aes(displ, hwy)) + geom_point()

ggplot(mpg) + geom_point(aes(displ, hwy))
