You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data: # a reference to the data frame arg you passed in
33
+
mapping: # a reference to the mapping arg you passed in
34
+
35
+
# these attributes are filled in by functions that you merge into this
36
+
# object with `+`
28
37
layers:
38
+
- geom: NULL
39
+
stat: NULL
40
+
data: NULL
41
+
mapping: NULL
42
+
position: NULL
43
+
params: list()
44
+
inherit.aes: TRUE
45
+
check.aes: TRUE
46
+
check.param: TRUE
47
+
show.legend: NA
48
+
key_glyph: NULL
49
+
layer_class: Layer
50
+
- geom: NULL
51
+
stat: NULL
52
+
data: NULL
53
+
mapping: NULL
54
+
position: NULL
55
+
params: list()
56
+
inherit.aes: TRUE
57
+
check.aes: TRUE
58
+
check.param: TRUE
59
+
show.legend: NA
60
+
key_glyph: NULL
61
+
layer_class: Layer
29
62
scales:
30
-
theme:
31
63
coordinates:
32
64
facet:
33
65
plot_env:
34
66
labels:
67
+
theme:
35
68
```
36
69
37
-
## aes(key = value, ...)
70
+
## aes()
38
71
39
72
* Build an aesthetic map (map in the sense of dictionary alike object)
40
73
* the map is an S3 class
@@ -46,7 +79,7 @@ ggplot S3 object:
46
79
* You can save the mapping either
47
80
1. at the "root" of the graph by passing it to `ggplot()` - this makes this aesthetic mapping available to all subsequent layers unless overrideen by the particular layer
48
81
* this is just a developer convenience to allow you to reuse an aesthetic mapping easily
49
-
2. or you pass it to a specific layer by passing it to a `geom_*()` function
82
+
2. or you pass it to a specific layer i.e. `layer()` or one of its short-cut functions
50
83
* if you pass a mapping in both places they will be combined by default (but this can be controlled by an arg to the layer functions)
A layer is a combination of data, stat and geom with a potential position adjustment. Usually layers are created using geom_* or stat_* calls but it can also be created directly using this function.
71
106
107
+
```
108
+
layer(
109
+
geom = NULL,
110
+
stat = NULL,
111
+
data = NULL,
112
+
mapping = NULL,
113
+
position = NULL,
114
+
params = list(),
115
+
inherit.aes = TRUE,
116
+
check.aes = TRUE,
117
+
check.param = TRUE,
118
+
show.legend = NA,
119
+
key_glyph = NULL,
120
+
layer_class = Layer
121
+
)
122
+
```
123
+
124
+
```r
125
+
# geom calls are just a short cut for layer
126
+
ggplot(mpg, aes(displ, hwy)) + geom_point()
127
+
128
+
# shortcut for
129
+
130
+
ggplot() +
131
+
layer(
132
+
data=mpg,
133
+
mapping= aes(x=displ, y=hwy),
134
+
geom="point",
135
+
stat="identity",
136
+
position="identity",
137
+
params=list(na.rm=FALSE)
138
+
)
139
+
140
+
# use a function as data to plot a subset of global data
0 commit comments