diff --git a/dev/articles/profiling.html b/dev/articles/profiling.html index 81cbcbc153..e6b4b63a36 100644 --- a/dev/articles/profiling.html +++ b/dev/articles/profiling.html @@ -135,7 +135,7 @@
In general, a minimal plot is used so that profiles are focused on +
In general, a minimal plot is used so that profiles are focused on low-level, general code, rather than implementations of specific geoms. This might be expanded at the point where improving performance of specific geoms becomes a focus. Further, the profile focuses on the diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 2bd3fade72..861106f7dc 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -13,7 +13,7 @@ articles: ggplot2-specs: ggplot2-specs.html ggplot2: ggplot2.html profiling: profiling.html -last_built: 2024-10-07T16:19Z +last_built: 2024-10-11T07:27Z urls: reference: https://ggplot2.tidyverse.org/reference article: https://ggplot2.tidyverse.org/articles diff --git a/dev/reference/aes_eval.html b/dev/reference/aes_eval.html index 07df455217..5e2fc92b44 100644 --- a/dev/reference/aes_eval.html +++ b/dev/reference/aes_eval.html @@ -135,7 +135,7 @@
Below follows an overview of the three stages of evaluation and how aesthetic evaluation can be controlled.
The default is to map at the beginning, using the layer data provided by @@ -195,15 +195,17 @@
If you want to map the same aesthetic multiple times, e.g. map x
to a
-data column for the stat, but remap it for the geom, you can use the
-stage()
function to collect multiple mappings.
Sometimes, you may want to map the same aesthetic multiple times, e.g. map
+x
to a data column at the start for the layer stat, but remap it later to
+a variable from the stat transformation for the layer geom. The stage()
+function allows you to control multiple mappings for the same aesthetic
+across all three stages of evaluation.
# Use stage to modify the scaled fill
ggplot(mpg, aes(class, hwy)) +
geom_boxplot(aes(fill = stage(class, after_scale = alpha(fill, 0.4))))
# Using data for computing summary, but placing label elsewhere.
-# Also, we're making our own computed variable to use for the label.
+# Also, we're making our own computed variables to use for the label.
ggplot(mpg, aes(class, displ)) +
geom_violin() +
stat_summary(
@@ -214,6 +216,10 @@ Complex staging geom = "text",
fun.data = ~ round(data.frame(mean = mean(.x), sd = sd(.x)), 2)
)
Conceptually, aes(x)
is equivalent to aes(stage(start = x))
, and
+aes(after_stat(count))
is equivalent to aes(stage(after_stat = count))
,
+and so on. stage()
is most useful when at least two of its arguments are
+specified.
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point())
#> step user.self sys.self elapsed
-#> 1 construct 0.003 0 0.002
-#> 2 build 0.019 0 0.019
-#> 3 render 0.019 0 0.018
-#> 4 draw 0.019 0 0.018
-#> 5 TOTAL 0.060 0 0.057
+#> 1 construct 0.003 0 0.003
+#> 2 build 0.019 0 0.018
+#> 3 render 0.019 0 0.019
+#> 4 draw 0.019 0 0.019
+#> 5 TOTAL 0.060 0 0.059
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#> step user.self sys.self elapsed
-#> 1 construct 0.003 0 0.003
+#> 1 construct 0.002 0 0.002
#> 2 build 0.020 0 0.020
#> 3 render 0.044 0 0.044
-#> 4 draw 0.033 0 0.033
-#> 5 TOTAL 0.100 0 0.100
+#> 4 draw 0.032 0 0.032
+#> 5 TOTAL 0.098 0 0.098
# With tidy eval:
p <- expr(ggplot(mtcars, aes(mpg, wt)) + geom_point())
benchplot(!!p)
#> step user.self sys.self elapsed
-#> 1 construct 0.002 0 0.003
-#> 2 build 0.019 0 0.020
-#> 3 render 0.019 0 0.019
-#> 4 draw 0.020 0 0.019
-#> 5 TOTAL 0.060 0 0.061
+#> 1 construct 0.002 0.000 0.002
+#> 2 build 0.018 0.000 0.019
+#> 3 render 0.015 0.004 0.019
+#> 4 draw 0.019 0.000 0.019
+#> 5 TOTAL 0.054 0.004 0.059