Skip to content

Commit 54a3b64

Browse files
committed
markdown source builds
Auto-generated via `{sandpaper}` Source : 626c366 Branch : main Author : Jia Qi <[email protected]> Time : 2025-02-13 11:56:40 +0000 Message : Merge pull request #113 from LibraryCarpentry/data-vis-aes-global-local-callout adding callout about aes global and local mappings
1 parent 419bdb2 commit 54a3b64

6 files changed

+22
-1
lines changed

04-data-viz-ggplot.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ ggplot(data = <DATA>, mapping = aes(<MAPPINGS>)) + <GEOM_FUNCTION>()
127127
- use the `ggplot()` function and bind the plot to a specific data frame using
128128
the `data` argument
129129

130+
::::::::::::::::::::::::::::::::::::::::::::; callout
131+
132+
**Note on Aesthetic Mappings:**
133+
In our basic template the `aes()` function is used inside `ggplot()`.
134+
135+
```r
136+
ggplot(data = <DATA>, mapping = aes(<MAPPINGS>)) + <GEOM_FUNCTION>()
137+
```
138+
139+
This sets **global** aesthetics that apply to all layers you add later, such as, geoms and scales. You might sometimes see the aesthetics defined inside a specific geom function like so:
140+
141+
```r
142+
ggplot(data = booksPlot) +
143+
geom_histogram(aes(x = tot_chkout), binwidth = 10) +
144+
scale_y_log10()
145+
```
146+
147+
In this case, the aesthetic mapping is **local** to `geom_histogram()`. This approach lets you specify or override settings for that particular layer without affecting others. In short, using `aes()` globally means every layer inherits the same settings, while using it locally gives you the flexibility to tailor individual layers as needed.
148+
149+
::::::::::
150+
130151
When you run the `ggplot()` function, it plots directly to the Plots tab in the
131152
Navigation Pane (lower right). Alternatively, you can assign a plot to an R
132153
object, then call `print()`to view the plot in the Navigation Pane.
339 Bytes
Loading
-471 Bytes
Loading
21 Bytes
Loading
72 Bytes
Loading

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"episodes/01-intro-to-r.Rmd" "eafb4aac57049aedb274d3ee92f88dfe" "site/built/01-intro-to-r.md" "2025-02-13"
88
"episodes/02-starting-with-data.Rmd" "f98fd114537492d825f2973be00351ce" "site/built/02-starting-with-data.md" "2025-02-05"
99
"episodes/03-data-cleaning-and-transformation.Rmd" "171cefcc18f972c2739cb3710fd241bd" "site/built/03-data-cleaning-and-transformation.md" "2025-02-05"
10-
"episodes/04-data-viz-ggplot.Rmd" "bbfac2f878e13a35dfbdef9ad3025521" "site/built/04-data-viz-ggplot.md" "2025-02-05"
10+
"episodes/04-data-viz-ggplot.Rmd" "5348e02fad9c23d88fbc9c892f00f6ed" "site/built/04-data-viz-ggplot.md" "2025-02-13"
1111
"instructors/instructor-notes.md" "a59fd3b94c07c3fe3218c054a0f03277" "site/built/instructor-notes.md" "2025-02-05"
1212
"learners/discuss.md" "2758e2e5abd231d82d25c6453d8abbc6" "site/built/discuss.md" "2025-02-05"
1313
"learners/reference.md" "dda49515f46cca6a1a8e7e195e66e73c" "site/built/reference.md" "2025-02-13"

0 commit comments

Comments
 (0)