From 1d59bd21e32cbc7fa84cccd2bc968cf3810a5d90 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Mon, 20 Oct 2025 09:54:39 +0200 Subject: [PATCH 1/2] Enhance explanation of drawing on plots in tinyplot Clarify the usage of drawing functions in tinyplot for facetted plots. --- vignettes/introduction.qmd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vignettes/introduction.qmd b/vignettes/introduction.qmd index 11f3bfe7..c6eb8182 100644 --- a/vignettes/introduction.qmd +++ b/vignettes/introduction.qmd @@ -483,8 +483,11 @@ 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 -demarcate some threshold values with horizontal or vertical lines, or simply -annotate your plot with text. The **tinyplot** way to do this is by passing the +demarcate some threshold values with horizontal or vertical lines using `abline()`, or simply +annotate your plot using `text()`. This works as usual with a regular plots, but not with +facetted plots because `text()`, `abline()`, `rect()`, etc. are not facet aware. + +The **tinyplot** way of adding common elements to facetted plots is by passing the `tinyplot(..., draw = )` argument. Here we demonstrate with a simplified version of our facet grid example from earlier. @@ -497,10 +500,8 @@ tinyplot( ) ``` -Compared to "manually" drawing these elements on a plot _ex post_---e.g., via a -separate `abline()` call---there are several advantages to the idiomatic -**tinyplot** interface. First, the `draw` argument is facet-aware and will -ensure that each individual facet is correctly drawn upon. Second, you can +This works becaause the `draw` argument is facet-aware and will +ensure that each individual facet is correctly drawn upon. Moreover, you can leverage the special `ii` internal counter to draw programmatically across facets (see [here](https://github.com/grantmcdermott/tinyplot/pull/245#issue-2642589951)). From 76f67322bf054c9c0227dd998f59faa09bd0482d Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Tue, 21 Oct 2025 10:09:13 +0200 Subject: [PATCH 2/2] Fix typo in introduction.qmd Corrected a typo in the explanation of the 'draw' argument. --- vignettes/introduction.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/introduction.qmd b/vignettes/introduction.qmd index c6eb8182..1a3d177c 100644 --- a/vignettes/introduction.qmd +++ b/vignettes/introduction.qmd @@ -500,8 +500,8 @@ tinyplot( ) ``` -This works becaause the `draw` argument is facet-aware and will -ensure that each individual facet is correctly drawn upon. Moreover, you can +This works because the `draw` argument is facet-aware and will +ensure that each individual facet is correctly drawn upon. Moreover, with `draw` you can leverage the special `ii` internal counter to draw programmatically across facets (see [here](https://github.com/grantmcdermott/tinyplot/pull/245#issue-2642589951)).