From 258e712208f45853257e8a70c5127858389f9f7e Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:41:26 -0700 Subject: [PATCH 01/17] switch up quakes bubble plot --- .../{points-quakes-hershey.R => bubble-quakes.R} | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) rename vignettes/gallery_figs/{points-quakes-hershey.R => bubble-quakes.R} (54%) diff --git a/vignettes/gallery_figs/points-quakes-hershey.R b/vignettes/gallery_figs/bubble-quakes.R similarity index 54% rename from vignettes/gallery_figs/points-quakes-hershey.R rename to vignettes/gallery_figs/bubble-quakes.R index 95008f9f..82cd1f4d 100644 --- a/vignettes/gallery_figs/points-quakes-hershey.R +++ b/vignettes/gallery_figs/bubble-quakes.R @@ -1,20 +1,25 @@ library(tinyplot) +magnitude = quakes$mag plt( lat ~ long | depth, data = quakes, + cex = magnitude, clim = c(0.5, 4.5), + col = "#3D3532", + fill = 0.7, pch = 21, main = "Earthquakes off Fiji", xlab = "Longitutde", ylab = "Latitude", - cap = "Data courtesy of the Harvard PRIM-H project", - palette = "mako", + sub = "Data courtesy of the Harvard PRIM-H project", + palette = "sunsetdark", # custom ephemeral theme theme = list( "dynamic", bty = "n", - bg = "#E0D9D2",# "#F7F3EF", + bg = "#E0D9D2", cex = 1.2, cex.main = 1.5, cex.lab = 1.2, col = "#3D3532", family = "HersheyScript", - grid = TRUE, grid.col = "gray95" + grid = TRUE, grid.col = "gray70", + lwd = 0.5 ) -) +) \ No newline at end of file From a23abfa7caa34d46435c5c0014f3ae993a838a1c Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:44:03 -0700 Subject: [PATCH 02/17] fix link --- vignettes/gallery.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 487ce38a..0a054752 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -93,8 +93,8 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/points-quakes-hershey.R){target='_blank'}" -#| file: "gallery_figs/points-quakes-hershey.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/bubble-quakes.R){target='_blank'}" +#| file: "gallery_figs/bubble-quakes.R" ``` ```{r} From 675f65eb316fbf1911190286ed4005c14bc2c9fd Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:46:31 -0700 Subject: [PATCH 03/17] pirate iris --- vignettes/gallery.qmd | 7 +++++++ vignettes/gallery_figs/pirate-iris.R | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 vignettes/gallery_figs/pirate-iris.R diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 0a054752..0f75fea5 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -111,6 +111,13 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/rect-by.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/pirate-iris.R){target='_blank'}" +#| file: "gallery_figs/pirate-iris.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/pirate-iris.R b/vignettes/gallery_figs/pirate-iris.R new file mode 100644 index 00000000..1ae6e6bf --- /dev/null +++ b/vignettes/gallery_figs/pirate-iris.R @@ -0,0 +1,28 @@ +library(tinyplot) + +# Register a custom "pirate" theme that builds on top of "clean" +tinytheme_register( + "pirate", + theme = "clean", + family = "HersheyScript", + bg = "#f5e6c8", fg = "#3b2209", + cex.lab = 1.5, cex.main = 1.5, cex.sub = 1.2, + col = "#3b2209", col.axis = "#5c3a1e", col.cap = "#7a5230", + col.lab = "#3b2209", col.main = "#1a0f04", col.sub = "#7a5230", + grid = TRUE, grid.col = "#c9a96e", grid.lty = "dotted", + facet.bg = "#e8d4a8", facet.border = "#5c3a1e", + pch = 4, + palette.qualitative = c( + "#8b0000", "#1a5276", "#196f3d", "#7d6608", + "#6c3483", "#a04000", "#1b4f72", "#145a32" + ) +) + +# Use it ephemerally +plt( + Sepal.Length ~ Petal.Length | Species, iris, + main = 'Avast, me hearties!', + sub = 'Here be a "pirate" theme', + cap = '"x" marks the spot', + theme = 'pirate' +) \ No newline at end of file From 64356b71d582013cb0212b4e6fb020098d11ba43 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:49:15 -0700 Subject: [PATCH 04/17] coefplot change up --- vignettes/gallery.qmd | 4 ++-- .../gallery_figs/{errorbar-mtcars.R => coefplot-mtcars.R} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename vignettes/gallery_figs/{errorbar-mtcars.R => coefplot-mtcars.R} (91%) diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 0f75fea5..223cfd66 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -100,8 +100,8 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/errorbar-mtcars.R){target='_blank'}" -#| file: "gallery_figs/errorbar-mtcars.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/coefplot-mtcars.R){target='_blank'}" +#| file: "gallery_figs/coefplot-mtcars.R" ``` ```{r} diff --git a/vignettes/gallery_figs/errorbar-mtcars.R b/vignettes/gallery_figs/coefplot-mtcars.R similarity index 91% rename from vignettes/gallery_figs/errorbar-mtcars.R rename to vignettes/gallery_figs/coefplot-mtcars.R index 4711a2b7..6da7421d 100644 --- a/vignettes/gallery_figs/errorbar-mtcars.R +++ b/vignettes/gallery_figs/coefplot-mtcars.R @@ -12,7 +12,7 @@ tinyplot( type = "errorbar", xlab = NA, ylab = "Estimate", flip = TRUE, - draw = abline(v = 0, lty = 2, col = "grey50"), + draw = abline(v = 0, lty = 2, col = "hotpink"), main = "Coefficient plot", sub = "Determinants of fuel efficiency", cap = expression(Model: mpg == beta[0] + beta[1] %.% wt + beta[2] %.% am + beta[3] %.% wt %.% am), From 6356c01157ff8d25714270d606ec9ac4d2d6497a Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:54:40 -0700 Subject: [PATCH 05/17] abline tweak --- vignettes/gallery_figs/add-ablines.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vignettes/gallery_figs/add-ablines.R b/vignettes/gallery_figs/add-ablines.R index 16f29303..49c477f2 100644 --- a/vignettes/gallery_figs/add-ablines.R +++ b/vignettes/gallery_figs/add-ablines.R @@ -1,10 +1,10 @@ library("tinyplot") tinyplot(mpg ~ hp | cyl, facet = "by", data = mtcars, - legend = FALSE, - theme = "classic", + legend = FALSE, cex = 2, alpha = 0.6, + theme = list("classic", facet.bg = "gray95"), main = "mtcars: Mileage vs horsepower", sub = "Faceted by no. of cylinders", cap = "Note: Dotted lines denote means") -tinyplot_add(type = type_hline(with(mtcars, tapply(mpg, cyl, mean))), lty = 2) -tinyplot_add(type = type_vline(with(mtcars, tapply(hp, cyl, mean))), lty = 2) +tinyplot_add(type = type_hline(with(mtcars, tapply(mpg, cyl, mean))), lty = 2, lwd = 1.5) +tinyplot_add(type = type_vline(with(mtcars, tapply(hp, cyl, mean))), lty = 2, lwd = 1.5) From faca10c344ed8c1f167f1622d2190135e795b2e0 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:57:50 -0700 Subject: [PATCH 06/17] polygons dark --- vignettes/gallery_figs/polygons.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vignettes/gallery_figs/polygons.R b/vignettes/gallery_figs/polygons.R index 0369ce73..0f9ad61d 100644 --- a/vignettes/gallery_figs/polygons.R +++ b/vignettes/gallery_figs/polygons.R @@ -4,5 +4,6 @@ plt( x = 1:9, y = c(2,1,2,1,NA,2,1,2,1), type = type_polygon(density = c(10, 20)), - theme = 'dynamic' + lwd = 2, + theme = 'dark' ) From 720bdcbc254e851477b1d8574a9e2223d1d5824b Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 17:59:46 -0700 Subject: [PATCH 07/17] use float theme --- vignettes/gallery_figs/points-iris-better.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vignettes/gallery_figs/points-iris-better.R b/vignettes/gallery_figs/points-iris-better.R index 23e9d18a..cb07a363 100644 --- a/vignettes/gallery_figs/points-iris-better.R +++ b/vignettes/gallery_figs/points-iris-better.R @@ -3,9 +3,6 @@ library(tinyplot) tinyplot( Sepal.Length ~ Petal.Length | Species, data = iris, - palette = "dark", - pch = 16, - grid = TRUE, - frame = FALSE, + theme = 'float', grid = TRUE, main = "A more exciting scatterplot" ) From 88b78d3b7ebd8a7ca0fd43d5323f1a96ff826c0d Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 16 Jun 2026 18:09:59 -0700 Subject: [PATCH 08/17] text tweak --- vignettes/gallery_figs/add-text-mtcars.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vignettes/gallery_figs/add-text-mtcars.R b/vignettes/gallery_figs/add-text-mtcars.R index bc9bdc84..0c592931 100644 --- a/vignettes/gallery_figs/add-text-mtcars.R +++ b/vignettes/gallery_figs/add-text-mtcars.R @@ -3,12 +3,15 @@ library("tinyplot") plt( mpg ~ hp | factor(cyl), data = mtcars, - legend = list("topright!", bty = "o"), - theme = "classic" + legend = list("topright!", bty = "o", title = "Cyclinders"), + xlab = "Gross horsepower", + ylab = "Miles per gallon", + theme = "classic" ) plt_add(type = type_text( labels = row.names(mtcars), adj = -0.05, srt = 15, - xpd = NA + xpd = NA, + repel = TRUE )) From b85125d95d296713b893d90daca37bd8ac3df117 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 09:08:10 -0700 Subject: [PATCH 09/17] likert --- altdoc/pkgdown.yml | 4 ++-- vignettes/gallery.qmd | 7 +++++++ vignettes/gallery_figs/likert.R | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 vignettes/gallery_figs/likert.R diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 534a46ad..eaabab3a 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -1,8 +1,8 @@ altdoc: 0.7.2 -pandoc: 3.9.0.2 +pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-04T16:46:48+0000 +last_built: 2026-06-17T01:17:24+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 223cfd66..b93f1c78 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -125,6 +125,13 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/add-text-mtcars.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/likert.R){target='_blank'}" +#| file: "gallery_figs/likert.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/likert.R b/vignettes/gallery_figs/likert.R new file mode 100644 index 00000000..e0bef14e --- /dev/null +++ b/vignettes/gallery_figs/likert.R @@ -0,0 +1,25 @@ +library(tinyplot) + +lik = expand.grid( + question = c("Pay", "Workload", "Manager", "Culture"), + response = c("Strong disagree", "Disagree", "Agree", "Strong agree", "Unsure") +) +lik$response = factor(lik$response, levels = unique(lik$response)) +lik$share = c( # proportions summing to 1 within each question + .10, .25, .05, .15, + .20, .30, .15, .20, + .35, .20, .40, .30, + .25, .15, .35, .20, + .10, .10, .05, .15 +) +# diverging palette: reds (disagree) -> blues (agree), grey for "Unsure" +pal = c("#b2182b", "#ef8a62", "#67a9cf", "#2166ac", "grey") +tinyplot( + share ~ question | response, data = lik, + type = "barplot", center = TRUE, offset = "Unsure", + flip = TRUE, xlab = NA, ylab = NA, yaxl = "percent", + legend = list("top!", title = NULL), + theme = list("clean2", palette.qualitative = pal), + main = "Hypothetical Likert example with category offset" +) +tinyplot_add(type = "vline") From 8abf3f15c4f273f45a44f4e9e29e855034f8dae8 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 10:00:49 -0700 Subject: [PATCH 10/17] tweak --- vignettes/gallery_figs/likert.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vignettes/gallery_figs/likert.R b/vignettes/gallery_figs/likert.R index e0bef14e..848968b9 100644 --- a/vignettes/gallery_figs/likert.R +++ b/vignettes/gallery_figs/likert.R @@ -1,5 +1,6 @@ library(tinyplot) +# construct fake likert data lik = expand.grid( question = c("Pay", "Workload", "Manager", "Culture"), response = c("Strong disagree", "Disagree", "Agree", "Strong agree", "Unsure") @@ -12,14 +13,16 @@ lik$share = c( # proportions summing to 1 within each question .25, .15, .35, .20, .10, .10, .05, .15 ) + # diverging palette: reds (disagree) -> blues (agree), grey for "Unsure" pal = c("#b2182b", "#ef8a62", "#67a9cf", "#2166ac", "grey") -tinyplot( + +plt( share ~ question | response, data = lik, type = "barplot", center = TRUE, offset = "Unsure", flip = TRUE, xlab = NA, ylab = NA, yaxl = "percent", legend = list("top!", title = NULL), theme = list("clean2", palette.qualitative = pal), - main = "Hypothetical Likert example with category offset" + main = "Likert example with \"Unsure\" category offset" ) -tinyplot_add(type = "vline") +plt_add(type = "vline") \ No newline at end of file From 32b30a13cf08fd87da8f64229daee7aeafefe68d Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 10:21:17 -0700 Subject: [PATCH 11/17] rearrange --- altdoc/pkgdown.yml | 2 +- vignettes/gallery.qmd | 48 ++++++++++++++++----------------- vignettes/gallery_figs/likert.R | 3 ++- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index eaabab3a..5f30262c 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-17T01:17:24+0000 +last_built: 2026-06-17T17:19:37+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index b93f1c78..2abc1548 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -58,22 +58,22 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" -#| file: "gallery_figs/add-points-rug-faithful.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/bubble-quakes.R){target='_blank'}" +#| file: "gallery_figs/bubble-quakes.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/direct-labels-aq.R){target='_blank'}" -#| file: "gallery_figs/direct-labels-aq.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" +#| file: "gallery_figs/add-points-rug-faithful.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/ridge-aq.R){target='_blank'}" -#| file: "gallery_figs/ridge-aq.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/direct-labels-aq.R){target='_blank'}" +#| file: "gallery_figs/direct-labels-aq.R" ``` ```{r} @@ -86,36 +86,36 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/spineplot-titanic.R){target='_blank'}" -#| file: "gallery_figs/spineplot-titanic.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/ridge-aq.R){target='_blank'}" +#| file: "gallery_figs/ridge-aq.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/bubble-quakes.R){target='_blank'}" -#| file: "gallery_figs/bubble-quakes.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/likert.R){target='_blank'}" +#| file: "gallery_figs/likert.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/coefplot-mtcars.R){target='_blank'}" -#| file: "gallery_figs/coefplot-mtcars.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/spineplot-titanic.R){target='_blank'}" +#| file: "gallery_figs/spineplot-titanic.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/rect-by.R){target='_blank'}" -#| file: "gallery_figs/rect-by.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/coefplot-mtcars.R){target='_blank'}" +#| file: "gallery_figs/coefplot-mtcars.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/pirate-iris.R){target='_blank'}" -#| file: "gallery_figs/pirate-iris.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-ablines.R){target='_blank'}" +#| file: "gallery_figs/add-ablines.R" ``` ```{r} @@ -128,29 +128,29 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/likert.R){target='_blank'}" -#| file: "gallery_figs/likert.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/pirate-iris.R){target='_blank'}" +#| file: "gallery_figs/pirate-iris.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-ablines.R){target='_blank'}" -#| file: "gallery_figs/add-ablines.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/rect-by.R){target='_blank'}" +#| file: "gallery_figs/rect-by.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/density-part-shading.R){target='_blank'}" -#| file: "gallery_figs/density-part-shading.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/polygons.R){target='_blank'}" +#| file: "gallery_figs/polygons.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/polygons.R){target='_blank'}" -#| file: "gallery_figs/polygons.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/density-part-shading.R){target='_blank'}" +#| file: "gallery_figs/density-part-shading.R" ``` ```{r} diff --git a/vignettes/gallery_figs/likert.R b/vignettes/gallery_figs/likert.R index 848968b9..6823bbbe 100644 --- a/vignettes/gallery_figs/likert.R +++ b/vignettes/gallery_figs/likert.R @@ -25,4 +25,5 @@ plt( theme = list("clean2", palette.qualitative = pal), main = "Likert example with \"Unsure\" category offset" ) -plt_add(type = "vline") \ No newline at end of file +plt_add(type = "vline") +# plt_add(type = "vline", v = 1, lty = 2) ## optional From 1d019a957c40a52737ab7d0c0d1648ab5411b009 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 18:10:38 -0700 Subject: [PATCH 12/17] update text plot --- altdoc/pkgdown.yml | 2 +- vignettes/gallery_figs/add-text-mtcars.R | 49 +++++++++++++++++------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 5f30262c..b14989b8 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-17T17:19:37+0000 +last_built: 2026-06-18T01:09:16+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery_figs/add-text-mtcars.R b/vignettes/gallery_figs/add-text-mtcars.R index 0c592931..6da158da 100644 --- a/vignettes/gallery_figs/add-text-mtcars.R +++ b/vignettes/gallery_figs/add-text-mtcars.R @@ -1,17 +1,40 @@ library("tinyplot") +mtcars2 = within( + mtcars, { + make = sub(" .*", "", row.names(mtcars)) + model = sub("^\\S+\\s+", "", row.names(mtcars)) + merc = factor(ifelse(make == "Merc", "Mercedes", "Other"), levels = c("Other", "Mercedes")) + } +) + plt( - mpg ~ hp | factor(cyl), - data = mtcars, - legend = list("topright!", bty = "o", title = "Cyclinders"), - xlab = "Gross horsepower", - ylab = "Miles per gallon", - theme = "classic" + qsec ~ mpg | merc, + data = mtcars2, + legend = list(title = NULL), + ylab = "1/4 mile time (s)", + xlab = "Miles per gallon", + main = "Performance vs efficiency", + sub = "Mercedes vs the rest", + cap = "Notes: Model numbers highlighted in text", + theme = list("web", palette.qualitative = c("#0FCFC0", "#F79CD4")) +) +plt_add( + type = "text", labels = mtcars2$model, repel = TRUE, xpd = NA, pos = 4, + alpha = 0.4 +) +plt_add( + data = subset(mtcars2, make=="Merc") ) -plt_add(type = type_text( - labels = row.names(mtcars), - adj = -0.05, - srt = 15, - xpd = NA, - repel = TRUE -)) +plt_add( + data = subset(mtcars2, make=="Merc"), + type = "text", labels = subset(mtcars2, make == "Merc")$model, + repel = TRUE, xpd = NA, pos = 4, font = 2 +) + +# optional annotations +arrows(12, 19, 12, 23, length = 0.1, angle = 20, col = "darkgrey", xpd = NA) +text(12, mean(c(19, 23)), "slower", srt = 90, adj = c(0.5, 1.5), col = "darkgrey", font = 3) +arrows(24, 15, 34.5, 15, length = 0.1, angle = 20, col = "darkgrey", xpd = NA) +text(mean(c(24, 34.5)), 15, "thriftier", adj = c(0.5, -1), col = "darkgrey", font = 3) + From a95e2f01dbe8dc60000e8b3d2c5399d6d426cd26 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 18:11:25 -0700 Subject: [PATCH 13/17] tweak --- vignettes/gallery_figs/add-text-mtcars.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/gallery_figs/add-text-mtcars.R b/vignettes/gallery_figs/add-text-mtcars.R index 6da158da..b9461205 100644 --- a/vignettes/gallery_figs/add-text-mtcars.R +++ b/vignettes/gallery_figs/add-text-mtcars.R @@ -21,7 +21,7 @@ plt( ) plt_add( type = "text", labels = mtcars2$model, repel = TRUE, xpd = NA, pos = 4, - alpha = 0.4 + alpha = 0.3 ) plt_add( data = subset(mtcars2, make=="Merc") From 650f82b295564ac4ac00b17f5c17e154855fa315 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 21:41:27 -0700 Subject: [PATCH 14/17] add simpson's paradox --- altdoc/pkgdown.yml | 2 +- vignettes/gallery.qmd | 7 +++++++ vignettes/gallery_figs/simpsons-paradox.R | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 vignettes/gallery_figs/simpsons-paradox.R diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index b14989b8..435fbb1a 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-18T01:09:16+0000 +last_built: 2026-06-18T04:38:19+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 2abc1548..0a5d7f22 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -111,6 +111,13 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/coefplot-mtcars.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/simpsons-paradox.R){target='_blank'}" +#| file: "gallery_figs/simpsons-paradox.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/simpsons-paradox.R b/vignettes/gallery_figs/simpsons-paradox.R new file mode 100644 index 00000000..17d7979f --- /dev/null +++ b/vignettes/gallery_figs/simpsons-paradox.R @@ -0,0 +1,17 @@ +library(tinyplot) + +op = par(pch = 15) +plt( + bill_dep ~ bill_len | species, data = penguins, + pch = "by", + cex = 1.2, alpha = 0.5, + xlab = "Bill length (mm)", + ylab = "Bill depth (mm)", + main = "Simpson's paradox", + sub = "Penguin bill dimensions", + cap = "Notes: 1) Front colour ribbons = group-wise linear fit.\n2) Background grey ribbon = pooled linear fit.", + theme = "clean2", + draw = plt_add(bill_dep ~ bill_len, type = "lm", col = "gray50") +) +plt_add(type = "lm") +par(op) From 11b8405541b2a92cbdf1f70110dbb0493686f6a7 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 17 Jun 2026 22:02:04 -0700 Subject: [PATCH 15/17] add spaghetti plot --- altdoc/pkgdown.yml | 2 +- vignettes/gallery.qmd | 11 +++++++++-- vignettes/gallery_figs/direct-labels-aq.R | 2 +- vignettes/gallery_figs/spaghetti-aq.R | 13 +++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 vignettes/gallery_figs/spaghetti-aq.R diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 435fbb1a..91467da5 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-18T04:38:19+0000 +last_built: 2026-06-18T05:00:45+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 0a5d7f22..c6bfcf35 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -65,8 +65,8 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" -#| file: "gallery_figs/add-points-rug-faithful.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/spaghetti-aq.R){target='_blank'}" +#| file: "gallery_figs/spaghetti-aq.R" ``` ```{r} @@ -118,6 +118,13 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/simpsons-paradox.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" +#| file: "gallery_figs/add-points-rug-faithful.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/direct-labels-aq.R b/vignettes/gallery_figs/direct-labels-aq.R index 93af6278..c3b1c0a6 100644 --- a/vignettes/gallery_figs/direct-labels-aq.R +++ b/vignettes/gallery_figs/direct-labels-aq.R @@ -3,7 +3,7 @@ library(tinyplot) aq = airquality aq$Month = factor(month.name[aq$Month], levels = month.name[5:9]) -tinyplot( +plt( Temp ~ Day | Month, data = aq, type = "l", diff --git a/vignettes/gallery_figs/spaghetti-aq.R b/vignettes/gallery_figs/spaghetti-aq.R new file mode 100644 index 00000000..553216a3 --- /dev/null +++ b/vignettes/gallery_figs/spaghetti-aq.R @@ -0,0 +1,13 @@ +library(tinyplot) + +aq = airquality +aq$Month = factor(month.name[aq$Month], levels = month.name[5:9]) + +plt( + Temp ~ Day | Month, aq, facet = "by", lwd = 3, type = "l", + legend = FALSE, + draw = plt_add(col = "grey", facet = NULL, lwd = 1), + main = "Temperatures by month", + sub = "Sometimes, spaghetti plots are the right choice", + theme = "float", ylim = c(50, 100), frame = FALSE +) From 8cf5a6a9e5866c9db7c8e33d442d8906926577b3 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Thu, 18 Jun 2026 08:58:27 -0700 Subject: [PATCH 16/17] better simpson's paradox figure --- altdoc/pkgdown.yml | 2 +- vignettes/gallery_figs/simpsons-paradox.R | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 91467da5..3e1e1c84 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-18T05:00:45+0000 +last_built: 2026-06-18T15:55:30+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery_figs/simpsons-paradox.R b/vignettes/gallery_figs/simpsons-paradox.R index 17d7979f..73a5ff73 100644 --- a/vignettes/gallery_figs/simpsons-paradox.R +++ b/vignettes/gallery_figs/simpsons-paradox.R @@ -1,17 +1,14 @@ library(tinyplot) -op = par(pch = 15) plt( bill_dep ~ bill_len | species, data = penguins, - pch = "by", - cex = 1.2, alpha = 0.5, - xlab = "Bill length (mm)", - ylab = "Bill depth (mm)", - main = "Simpson's paradox", - sub = "Penguin bill dimensions", - cap = "Notes: 1) Front colour ribbons = group-wise linear fit.\n2) Background grey ribbon = pooled linear fit.", - theme = "clean2", - draw = plt_add(bill_dep ~ bill_len, type = "lm", col = "gray50") + pch = c(21, 24, 22), fill = 0.6, cex = 1.2, + main = "Bill dimensions for different penguin species", + sub = "Illustration of Simpson's paradox", + cap = "Notes: Lines show OLS fit for species-specific (solid) vs. pooled (dotted grey) samples.", + xlab = "Bill length (mm)", ylab = "Bill depth (mm)", + legend = list("bottomright", title = "Species", bty = "o", lty = 1), + theme = list("minimal", palette.qualitative = c("darkorange", "purple", "cyan4")) ) -plt_add(type = "lm") -par(op) +plt_add(type = type_lm(se = FALSE), lwd = 2) +plt_add(bill_dep ~ bill_len, type = type_lm(se = FALSE), lwd = 2, lty = 2, col = "darkgray") From d87418462b1aef28f8d6d22eb14e4b50318d7164 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Thu, 18 Jun 2026 09:01:28 -0700 Subject: [PATCH 17/17] aesthetic (arrangement) tweak --- altdoc/pkgdown.yml | 2 +- vignettes/gallery.qmd | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 3e1e1c84..33958252 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -2,7 +2,7 @@ altdoc: 0.7.2 pandoc: '3.10' pkgdown: 2.1.3 pkgdown_sha: ~ -last_built: 2026-06-18T15:55:30+0000 +last_built: 2026-06-18T16:00:18+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index c6bfcf35..174739a6 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -121,15 +121,15 @@ Click on a plot to get the link to its code. ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" -#| file: "gallery_figs/add-points-rug-faithful.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-ablines.R){target='_blank'}" +#| file: "gallery_figs/add-ablines.R" ``` ```{r} #| lightbox: #| group: r-graph -#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-ablines.R){target='_blank'}" -#| file: "gallery_figs/add-ablines.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/add-points-rug-faithful.R){target='_blank'}" +#| file: "gallery_figs/add-points-rug-faithful.R" ``` ```{r}