From affaf3baea516d88345a0bf06960379f1a0e893c Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Wed, 20 Nov 2024 10:03:32 -0500 Subject: [PATCH 1/2] intro plt() alias discussion --- vignettes/introduction.qmd | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/vignettes/introduction.qmd b/vignettes/introduction.qmd index 4f9821e5..22375a20 100644 --- a/vignettes/introduction.qmd +++ b/vignettes/introduction.qmd @@ -63,21 +63,8 @@ earlier. tinyplot(Temp ~ Day, data = aq) # formula method ``` -### Aside: `plt` shorthand - -If you'd prefer to save on a few keystrokes, you can use the shorthand `plt` -alias instead of typing out `tinyplot`. - -```{r plt_simple} -plt(Temp ~ Day, data = aq) # `plt` = shorthand alias for `tinyplot` -``` - -Please note that the `plt` shorthand would work for all of the remaining -plot calls below. But we'll stick to `tinyplot` to avoid any potential -confusion. - ::: {.callout-tip} -Use the `plt()` alias instead of `tinyplot()` to save yourself a few keystrokes. +Use the `plt()` alias instead of `tinyplot()` to save yourself a few keystrokes. The function and its alias produce identical results. ::: ## Grouped data From cf215a80b4051f1b81824ba1658c7629d4aa5c91 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Sun, 12 Jan 2025 17:51:36 -0800 Subject: [PATCH 2/2] tweaks --- vignettes/introduction.qmd | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/vignettes/introduction.qmd b/vignettes/introduction.qmd index 22375a20..3159337f 100644 --- a/vignettes/introduction.qmd +++ b/vignettes/introduction.qmd @@ -64,7 +64,18 @@ tinyplot(Temp ~ Day, data = aq) # formula method ``` ::: {.callout-tip} -Use the `plt()` alias instead of `tinyplot()` to save yourself a few keystrokes. The function and its alias produce identical results. +## Tip: `plt()` shorthand alias + +Use the `plt()` alias instead of `tinyplot()` to save yourself a few keystrokes. +For example: + +```{r plt_simple} +#| eval: false +plt(Temp ~ Day, data = aq) +``` + +Feel free to try this shorthand with any of the plots that follow; `tinyplot()` +and `plt()` should produce identical results. ::: ## Grouped data @@ -430,7 +441,7 @@ become verbose since it requires users to make very similar successive calls, with many shared arguments. For this reason, the **tinyplot** package provides a special -`tinyplot_add()` (alias `plt_add()`) convenience function for adding layers to +`tinyplot_add()` convenience function for adding layers to an existing tinyplot. The idea is that users need simply pass the _specific_ arguments that they want to add or modify relative to the base layer, and all arguments will be inherited from the original. @@ -456,6 +467,18 @@ tinyplot( tinyplot_add(type = "lm") ``` +::: {.callout-tip} +## Tip: `plt_add()` shorthand alias + +Much like `plt()` is an alias for `tinyplot()`, you can save yourself a few +keystrokes by typing `plt_add()` instead of `tinyplot_add()`: + +```{r plt_add} +#| eval: false +plt_add(type = "lm") +``` +::: + A related---but distinct---concept to adding plot layers is _drawing_ on a plot. The canonical use case is annotating your plot with text or some other function-based (rather than data-based) logic. For example, you may want to