From df6001480964bd9bcfa69b500f892b63369ac886 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Fri, 19 Jun 2026 04:15:35 +0200 Subject: [PATCH 01/10] line plots for time series (IPCC & EuStockMarkets) --- vignettes/gallery.qmd | 14 ++++++ vignettes/gallery_figs/line-eustockmarkets.R | 18 ++++++++ vignettes/gallery_figs/line-ipcc.R | 45 ++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 vignettes/gallery_figs/line-eustockmarkets.R create mode 100644 vignettes/gallery_figs/line-ipcc.R diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index dc7e6978..f55c523f 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -76,6 +76,20 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/direct-labels-aq.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/line-ipcc.R){target='_blank'}" +#| file: "gallery_figs/line-ipcc.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/line-eustockmarkets.R){target='_blank'}" +#| file: "gallery_figs/line-eustockmarkets.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/line-eustockmarkets.R b/vignettes/gallery_figs/line-eustockmarkets.R new file mode 100644 index 00000000..264965a3 --- /dev/null +++ b/vignettes/gallery_figs/line-eustockmarkets.R @@ -0,0 +1,18 @@ +data("EuStockMarkets", package = "datasets") +eu = data.frame( + time = rep(time(EuStockMarkets), ncol(EuStockMarkets)), + market = rep(colnames(EuStockMarkets), each = nrow(EuStockMarkets)), + value = as.numeric(EuStockMarkets) +) + +library("tinyplot") +tinyplot( + value ~ time | market, + data = eu, + facet = "by", + type = "l", + theme = "clean2", + legend = FALSE, + xlab = "", + ylab = "" +) diff --git a/vignettes/gallery_figs/line-ipcc.R b/vignettes/gallery_figs/line-ipcc.R new file mode 100644 index 00000000..864410f2 --- /dev/null +++ b/vignettes/gallery_figs/line-ipcc.R @@ -0,0 +1,45 @@ +ipcc = data.frame( + scenario = rep(c("", "SSP1 - 1.9", "SSP1 - 2.6", "SSP2 - 4.5", "SSP3 - 7.0", "SSP5 - 8.5"), c(65, 85, 85, 85, 85, 85)), + year = c(1950:2014, rep(2015:2099, 5)), + temperature = c( + 0.252, 0.275, 0.274, 0.253, 0.246, 0.273, 0.270, 0.268, 0.259, 0.258, 0.276, 0.279, 0.243, 0.146, 0.068, 0.089, 0.137, 0.132, 0.163, 0.198, 0.212, 0.229, + 0.203, 0.226, 0.247, 0.212, 0.220, 0.278, 0.282, 0.311, 0.347, 0.378, 0.337, 0.232, 0.303, 0.355, 0.388, 0.438, 0.472, 0.516, 0.586, 0.565, 0.292, 0.348, + 0.450, 0.491, 0.566, 0.638, 0.646, 0.682, 0.735, 0.799, 0.820, 0.856, 0.866, 0.884, 0.899, 0.929, 0.943, 0.962, 1.003, 1.036, 1.061, 1.085, 1.100, + 1.099, 1.123, 1.149, 1.175, 1.201, 1.225, 1.252, 1.277, 1.300, 1.321, 1.344, 1.367, 1.388, 1.407, 1.426, 1.444, 1.459, 1.474, 1.488, 1.499, 1.510, 1.520, + 1.528, 1.535, 1.543, 1.550, 1.554, 1.559, 1.563, 1.566, 1.568, 1.567, 1.567, 1.567, 1.566, 1.565, 1.565, 1.563, 1.561, 1.560, 1.557, 1.553, 1.550, 1.547, + 1.544, 1.540, 1.537, 1.533, 1.529, 1.525, 1.521, 1.518, 1.514, 1.511, 1.507, 1.503, 1.499, 1.496, 1.492, 1.489, 1.487, 1.483, 1.479, 1.475, 1.469, 1.464, + 1.459, 1.455, 1.451, 1.447, 1.444, 1.439, 1.434, 1.430, 1.424, 1.418, 1.414, 1.411, 1.407, 1.403, 1.400, 1.396, 1.392, 1.388, 1.385, + 1.099, 1.125, 1.151, 1.177, 1.202, 1.229, 1.254, 1.279, 1.302, 1.325, 1.351, 1.373, 1.396, 1.417, 1.440, 1.461, 1.480, 1.499, 1.518, 1.534, 1.550, 1.565, + 1.579, 1.595, 1.610, 1.622, 1.635, 1.648, 1.660, 1.670, 1.680, 1.691, 1.700, 1.708, 1.716, 1.724, 1.733, 1.740, 1.747, 1.754, 1.760, 1.766, 1.770, 1.774, + 1.778, 1.783, 1.786, 1.788, 1.792, 1.795, 1.797, 1.799, 1.799, 1.799, 1.801, 1.801, 1.800, 1.801, 1.800, 1.799, 1.799, 1.798, 1.796, 1.794, 1.792, 1.789, + 1.787, 1.784, 1.781, 1.778, 1.775, 1.772, 1.769, 1.764, 1.761, 1.759, 1.754, 1.750, 1.746, 1.742, 1.739, 1.735, 1.732, 1.727, 1.724, + 1.103, 1.127, 1.152, 1.177, 1.203, 1.230, 1.256, 1.281, 1.307, 1.333, 1.358, 1.381, 1.406, 1.433, 1.458, 1.483, 1.506, 1.529, 1.551, 1.573, 1.594, 1.617, + 1.641, 1.665, 1.689, 1.712, 1.737, 1.762, 1.787, 1.809, 1.831, 1.855, 1.880, 1.902, 1.922, 1.946, 1.973, 1.994, 2.017, 2.039, 2.061, 2.084, 2.104, 2.125, + 2.146, 2.165, 2.186, 2.205, 2.225, 2.245, 2.263, 2.281, 2.298, 2.316, 2.334, 2.350, 2.366, 2.386, 2.401, 2.421, 2.437, 2.449, 2.469, 2.485, 2.499, 2.513, + 2.527, 2.542, 2.557, 2.572, 2.586, 2.601, 2.614, 2.627, 2.639, 2.650, 2.665, 2.675, 2.687, 2.698, 2.710, 2.721, 2.730, 2.740, 2.748, + 1.094, 1.118, 1.143, 1.170, 1.195, 1.220, 1.247, 1.273, 1.299, 1.324, 1.349, 1.376, 1.403, 1.432, 1.460, 1.488, 1.517, 1.546, 1.574, 1.602, 1.630, 1.660, + 1.691, 1.720, 1.749, 1.781, 1.815, 1.847, 1.876, 1.908, 1.940, 1.974, 2.006, 2.037, 2.066, 2.101, 2.133, 2.167, 2.200, 2.235, 2.268, 2.300, 2.334, 2.368, + 2.404, 2.439, 2.473, 2.510, 2.547, 2.584, 2.622, 2.659, 2.696, 2.730, 2.765, 2.799, 2.837, 2.876, 2.912, 2.950, 2.987, 3.028, 3.066, 3.102, 3.141, 3.181, + 3.218, 3.254, 3.293, 3.332, 3.371, 3.409, 3.448, 3.490, 3.530, 3.568, 3.606, 3.645, 3.684, 3.721, 3.758, 3.796, 3.835, 3.872, 3.909, + 1.110, 1.137, 1.166, 1.195, 1.224, 1.254, 1.283, 1.316, 1.347, 1.377, 1.410, 1.442, 1.475, 1.509, 1.544, 1.577, 1.610, 1.644, 1.678, 1.713, 1.748, 1.783, + 1.818, 1.854, 1.892, 1.933, 1.973, 2.011, 2.052, 2.094, 2.136, 2.178, 2.219, 2.261, 2.304, 2.348, 2.393, 2.439, 2.486, 2.531, 2.573, 2.619, 2.668, 2.713, + 2.757, 2.797, 2.845, 2.893, 2.942, 2.989, 3.036, 3.086, 3.135, 3.181, 3.229, 3.280, 3.329, 3.376, 3.426, 3.478, 3.528, 3.579, 3.630, 3.679, 3.734, 3.784, + 3.833, 3.886, 3.939, 3.990, 4.042, 4.093, 4.145, 4.198, 4.249, 4.300, 4.351, 4.402, 4.451, 4.499, 4.549, 4.597, 4.644, 4.690, 4.735)) + +library("tinyplot") +tinyplot( + temperature ~ year | scenario, + data = ipcc, + type = "l", + theme = "clean2", + col = c("#000000", "#00a9d1", "#29416e", "#e58c35", "#dd4048", "#942324"), + lwd = 3, + grid = "xY", + legend = "direct", + main = "Global surface temperature change relative to 1850-1900", + sub = "Intergovernmental Panel on Climate Change (IPCC), Sixth Assessment Report", + xlab = "", + ylab = "Temperature change [°C]" +) + + From 0c3e5fe4a1b8a47c3d9e6ce8aa245126c93f6bf5 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Fri, 19 Jun 2026 04:39:27 +0200 Subject: [PATCH 02/10] barplots (FIFA 2026 forecast & penguins) --- vignettes/gallery.qmd | 14 +++++++++ vignettes/gallery_figs/barplot-fifa2026.R | 35 +++++++++++++++++++++++ vignettes/gallery_figs/barplot-penguins.R | 15 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 vignettes/gallery_figs/barplot-fifa2026.R create mode 100644 vignettes/gallery_figs/barplot-penguins.R diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index f55c523f..2c715f3b 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -104,6 +104,20 @@ Click on a plot to get the link to its code. #| file: "gallery_figs/ridge-aq.R" ``` +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/barplot-fifa2026.R){target='_blank'}" +#| file: "gallery_figs/barplot-fifa2026.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/barplot-penguins.R){target='_blank'}" +#| file: "gallery_figs/barplot-penguins.R" +``` + ```{r} #| lightbox: #| group: r-graph diff --git a/vignettes/gallery_figs/barplot-fifa2026.R b/vignettes/gallery_figs/barplot-fifa2026.R new file mode 100644 index 00000000..ea1f01da --- /dev/null +++ b/vignettes/gallery_figs/barplot-fifa2026.R @@ -0,0 +1,35 @@ +fifa2026 = data.frame( + team = c("Spain", "England", "France", "Germany", "Portugal", "Argentina", "Netherlands", "Brazil", + "Belgium", "Norway", "Switzerland", "Croatia", "Colombia", "Japan", "Morocco", "United States", + "Uruguay", "Senegal", "Sweden", "Ecuador", "Austria", "Turkey", "Canada", "Mexico", "South Korea", + "Ivory Coast", "Algeria", "Australia", "Czech Republic", "Scotland", "Paraguay", "Egypt", + "Bosnia and Herzegovina", "DR Congo", "Ghana", "Tunisia", "Iran", "Cape Verde", "Uzbekistan", + "Panama", "Haiti", "New Zealand", "Saudi Arabia", "Curaçao", "South Africa", "Iraq", "Qatar", "Jordan"), + win = c(14462, 12426, 12365, 11246, 8909, 8240, 5576, 4720, 2992, 2602, 2083, 1373, 1303, 1274, 990, 954, + 945, 945, 886, 752, 657, 651, 616, 601, 481, 281, 250, 222, 212, 206, 143, 121, 113, 71, 70, 59, 36, + 31, 29, 26, 24, 18, 12, 11, 7, 6, 2, 1)/1e5 +) + +library("tinyplot") +tinyplot( + x = 1:48, + y = fifa2026$win, + type = "barplot", + yaxl = "%", + grid = "xY", + xlab = "", + ylab = "", + xaxt = "n", + main = "Spain most likely to (not) win the 2026 FIFA World Cup", + cap = "Source: https://www.zeileis.org/news/fifa2026/", + theme = list("clean2", grid.lty = 1, las = 2, dynmar = FALSE, mar = c(7, 4, 5, 0), cex.main = 1.5) +) +text( + 1:48, + 0, + labels = fifa2026$team, + srt = 45, + adj = c(1.15, 1.15), + xpd = TRUE, + cex = 0.8 +) diff --git a/vignettes/gallery_figs/barplot-penguins.R b/vignettes/gallery_figs/barplot-penguins.R new file mode 100644 index 00000000..d0c9d2f0 --- /dev/null +++ b/vignettes/gallery_figs/barplot-penguins.R @@ -0,0 +1,15 @@ +data("penguins", package = "datasets") +pal = c("darkorange", "purple", "cyan4") + +library("tinyplot") +tinytheme("minimal", las = 1) +tinyplot( + ~ island | sex + species, + facet = species ~ 1, + data = penguins, + type = "barplot", + flip = TRUE, + col = "transparent", + grid = "X", + bg = rbind(pal, colorspace::lighten(pal, 0.6)) +) From 501762ddefdd1542d133ac457a83a5c34d57d3e2 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Fri, 19 Jun 2026 04:52:53 +0200 Subject: [PATCH 03/10] tweak font sizes --- vignettes/gallery_figs/barplot-fifa2026.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/gallery_figs/barplot-fifa2026.R b/vignettes/gallery_figs/barplot-fifa2026.R index ea1f01da..4941d686 100644 --- a/vignettes/gallery_figs/barplot-fifa2026.R +++ b/vignettes/gallery_figs/barplot-fifa2026.R @@ -22,7 +22,7 @@ tinyplot( xaxt = "n", main = "Spain most likely to (not) win the 2026 FIFA World Cup", cap = "Source: https://www.zeileis.org/news/fifa2026/", - theme = list("clean2", grid.lty = 1, las = 2, dynmar = FALSE, mar = c(7, 4, 5, 0), cex.main = 1.5) + theme = list("clean2", grid.lty = 1, las = 2, dynmar = FALSE, mar = c(7, 4, 5, 0), cex.main = 1.3) ) text( 1:48, @@ -31,5 +31,5 @@ text( srt = 45, adj = c(1.15, 1.15), xpd = TRUE, - cex = 0.8 + cex = 0.5 ) From 3ab8c94175fad9834e41edaddab8d6ee0ba525d0 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Fri, 19 Jun 2026 07:36:55 +0200 Subject: [PATCH 04/10] try to use tinyplot:::seq_palette instead of colorspace::lighten --- vignettes/gallery_figs/barplot-penguins.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/gallery_figs/barplot-penguins.R b/vignettes/gallery_figs/barplot-penguins.R index d0c9d2f0..98f53b5d 100644 --- a/vignettes/gallery_figs/barplot-penguins.R +++ b/vignettes/gallery_figs/barplot-penguins.R @@ -11,5 +11,5 @@ tinyplot( flip = TRUE, col = "transparent", grid = "X", - bg = rbind(pal, colorspace::lighten(pal, 0.6)) + bg = sapply(pal, tinyplot:::seq_palette, 2) ## rbind(pal, colorspace::lighten(pal, 0.6)) ) From 878128b81d0f48977e3a033bc2259636782dfe54 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Fri, 19 Jun 2026 20:02:49 +0200 Subject: [PATCH 05/10] use colorspace::lighten again, colorspace added to DESCRIPTION/Suggests --- DESCRIPTION | 3 ++- vignettes/gallery_figs/barplot-penguins.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 89819c42..7ecdb614 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,7 +51,8 @@ Suggests: svglite (>= 2.2.0), tinytest, tinysnapshot (>= 0.0.3), - knitr + knitr, + colorspace Config/Needs/website: altdoc (>= 0.7.2), future.apply Encoding: UTF-8 URL: https://grantmcdermott.com/tinyplot/ diff --git a/vignettes/gallery_figs/barplot-penguins.R b/vignettes/gallery_figs/barplot-penguins.R index 98f53b5d..d0c9d2f0 100644 --- a/vignettes/gallery_figs/barplot-penguins.R +++ b/vignettes/gallery_figs/barplot-penguins.R @@ -11,5 +11,5 @@ tinyplot( flip = TRUE, col = "transparent", grid = "X", - bg = sapply(pal, tinyplot:::seq_palette, 2) ## rbind(pal, colorspace::lighten(pal, 0.6)) + bg = rbind(pal, colorspace::lighten(pal, 0.6)) ) From f9a846df89df880eb42a7fa153db25f619a16d54 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Sat, 20 Jun 2026 12:54:22 -0700 Subject: [PATCH 06/10] tweaks --- altdoc/pkgdown.yml | 2 +- vignettes/gallery_figs/barplot-fifa2026.R | 17 ++++++++--------- vignettes/gallery_figs/line-eustockmarkets.R | 11 +++++++---- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 1b5a07ba..c065689e 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-18T17:31:05+0000 +last_built: 2026-06-20T19:18:00+0000 urls: reference: https://grantmcdermott.com/tinyplot/man article: https://grantmcdermott.com/tinyplot/vignettes diff --git a/vignettes/gallery_figs/barplot-fifa2026.R b/vignettes/gallery_figs/barplot-fifa2026.R index 4941d686..ec6f4c2e 100644 --- a/vignettes/gallery_figs/barplot-fifa2026.R +++ b/vignettes/gallery_figs/barplot-fifa2026.R @@ -15,21 +15,20 @@ tinyplot( x = 1:48, y = fifa2026$win, type = "barplot", - yaxl = "%", - grid = "xY", - xlab = "", - ylab = "", + xlab = NA, + ylab = NA, xaxt = "n", + yaxl = "%", main = "Spain most likely to (not) win the 2026 FIFA World Cup", cap = "Source: https://www.zeileis.org/news/fifa2026/", - theme = list("clean2", grid.lty = 1, las = 2, dynmar = FALSE, mar = c(7, 4, 5, 0), cex.main = 1.3) + theme = list("broadsheet", mar = c(4, 0.1, 0.6, 0.6), col.default = "#2A9D8F") ) text( 1:48, - 0, + -0.001, labels = fifa2026$team, + adj = c(1, 1.15), + cex = 0.5, srt = 45, - adj = c(1.15, 1.15), - xpd = TRUE, - cex = 0.5 + xpd = TRUE ) diff --git a/vignettes/gallery_figs/line-eustockmarkets.R b/vignettes/gallery_figs/line-eustockmarkets.R index 264965a3..2e4e8d7b 100644 --- a/vignettes/gallery_figs/line-eustockmarkets.R +++ b/vignettes/gallery_figs/line-eustockmarkets.R @@ -1,4 +1,7 @@ +## note: replace with tinyplot.ts method once #558 is merged + data("EuStockMarkets", package = "datasets") + eu = data.frame( time = rep(time(EuStockMarkets), ncol(EuStockMarkets)), market = rep(colnames(EuStockMarkets), each = nrow(EuStockMarkets)), @@ -9,10 +12,10 @@ library("tinyplot") tinyplot( value ~ time | market, data = eu, - facet = "by", + facet = "by", legend = FALSE, type = "l", theme = "clean2", - legend = FALSE, - xlab = "", - ylab = "" + main = "EU Stock Markets Performance", + xlab = NA, ylab = NA, + yaxl = "," ) From a6b32d6d1dde39eb5f137d7ac90f7bb3cd96f98b Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Sun, 21 Jun 2026 11:58:21 +0200 Subject: [PATCH 07/10] add draw-abline/text for distinction of historical/projection --- vignettes/gallery_figs/line-ipcc.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vignettes/gallery_figs/line-ipcc.R b/vignettes/gallery_figs/line-ipcc.R index 864410f2..f73b00e6 100644 --- a/vignettes/gallery_figs/line-ipcc.R +++ b/vignettes/gallery_figs/line-ipcc.R @@ -31,7 +31,7 @@ tinyplot( temperature ~ year | scenario, data = ipcc, type = "l", - theme = "clean2", + theme = "socviz", col = c("#000000", "#00a9d1", "#29416e", "#e58c35", "#dd4048", "#942324"), lwd = 3, grid = "xY", @@ -39,7 +39,12 @@ tinyplot( main = "Global surface temperature change relative to 1850-1900", sub = "Intergovernmental Panel on Climate Change (IPCC), Sixth Assessment Report", xlab = "", - ylab = "Temperature change [°C]" + ylab = "Temperature change [°C]", + draw = { + abline(v = 2014.5, lty = 2, col = "gray60") + text(2014, 0, "Historical", pos = 2, col = "gray60") + text(2015, 0, "Projection", pos = 4, col = "gray60") + } ) From 9be546a520133322fa68a28898078df032a4d6af Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Sun, 21 Jun 2026 21:22:17 +0200 Subject: [PATCH 08/10] title in sentence case --- vignettes/gallery_figs/line-eustockmarkets.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/gallery_figs/line-eustockmarkets.R b/vignettes/gallery_figs/line-eustockmarkets.R index 2e4e8d7b..a71b8a16 100644 --- a/vignettes/gallery_figs/line-eustockmarkets.R +++ b/vignettes/gallery_figs/line-eustockmarkets.R @@ -15,7 +15,7 @@ tinyplot( facet = "by", legend = FALSE, type = "l", theme = "clean2", - main = "EU Stock Markets Performance", + main = "EU stock markets performance", xlab = NA, ylab = NA, yaxl = "," ) From 9a9850f98a2d135272e326ae5a0d28cd84f2a041 Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Sun, 21 Jun 2026 21:26:16 +0200 Subject: [PATCH 09/10] replace penguins barplot with meat consumption barplot (colorspace not needed anymore) --- DESCRIPTION | 3 +-- vignettes/gallery.qmd | 4 ++-- vignettes/gallery_figs/barplot-meat.R | 25 +++++++++++++++++++++++ vignettes/gallery_figs/barplot-penguins.R | 15 -------------- 4 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 vignettes/gallery_figs/barplot-meat.R delete mode 100644 vignettes/gallery_figs/barplot-penguins.R diff --git a/DESCRIPTION b/DESCRIPTION index 7ecdb614..89819c42 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,8 +51,7 @@ Suggests: svglite (>= 2.2.0), tinytest, tinysnapshot (>= 0.0.3), - knitr, - colorspace + knitr Config/Needs/website: altdoc (>= 0.7.2), future.apply Encoding: UTF-8 URL: https://grantmcdermott.com/tinyplot/ diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 2c715f3b..f1113852 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -114,8 +114,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/barplot-penguins.R){target='_blank'}" -#| file: "gallery_figs/barplot-penguins.R" +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/barplot-meat.R){target='_blank'}" +#| file: "gallery_figs/barplot-meat.R" ``` ```{r} diff --git a/vignettes/gallery_figs/barplot-meat.R b/vignettes/gallery_figs/barplot-meat.R new file mode 100644 index 00000000..bbdc1762 --- /dev/null +++ b/vignettes/gallery_figs/barplot-meat.R @@ -0,0 +1,25 @@ +meat = data.frame( + consumption = c(8.1, 14.6, 23.2, 30.8, 38, 0.7, 1.3, 4, 7.7, 9.2, 1.2, 1.7, 5.8, 10.3, 12.9, 4.5, + 6.8, 17.9, 27.4, 36.8, 28.5, 29.7, 29.6, 29.7, 27.4, 55.5, 49.2, 44.7, 43.8, 37.8, 22.7, 31.1, + 43.8, 50.9, 52.8, 15.2, 18.8, 21.8, 23, 21.6), + country = factor(rep(1:2, each = 20), labels = c("China", "United States")), + decade = factor(rep(paste0(197:201, "0s"), 8)), + type = factor(rep(c(1:4, 1:4), each = 5), labels = c("Pork", "Beef & other", "Poultry", "Fish & seafood")) +) + +library("tinyplot") +tinyplot( + consumption ~ decade | type, + facet = country ~ 1, + data = meat, + type = "barplot", + grid = "X", + flip = TRUE, + legend = list("bottom!", title = NULL), + theme = list("minimal", palette.qualitative = palette.colors(palette = "Set 3")[c(4, 6, 1, 5)]), + main = "Per capita meat and fish consumption by decade", + sub = "Measured in kilograms per person and year", + xlab = "", + ylab = "", + cap = "Source: Food and Agriculture Organization of the United Nations (via OurWorldInData.org)" +) diff --git a/vignettes/gallery_figs/barplot-penguins.R b/vignettes/gallery_figs/barplot-penguins.R deleted file mode 100644 index d0c9d2f0..00000000 --- a/vignettes/gallery_figs/barplot-penguins.R +++ /dev/null @@ -1,15 +0,0 @@ -data("penguins", package = "datasets") -pal = c("darkorange", "purple", "cyan4") - -library("tinyplot") -tinytheme("minimal", las = 1) -tinyplot( - ~ island | sex + species, - facet = species ~ 1, - data = penguins, - type = "barplot", - flip = TRUE, - col = "transparent", - grid = "X", - bg = rbind(pal, colorspace::lighten(pal, 0.6)) -) From 8296c27aab713104a81d293b5d461e6cbe6aaf7f Mon Sep 17 00:00:00 2001 From: Achim Zeileis Date: Sun, 21 Jun 2026 21:44:55 +0200 Subject: [PATCH 10/10] named vector input is a bit more compact than data.frame --- vignettes/gallery_figs/barplot-fifa2026.R | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/vignettes/gallery_figs/barplot-fifa2026.R b/vignettes/gallery_figs/barplot-fifa2026.R index ec6f4c2e..4f4cf2bf 100644 --- a/vignettes/gallery_figs/barplot-fifa2026.R +++ b/vignettes/gallery_figs/barplot-fifa2026.R @@ -1,19 +1,16 @@ -fifa2026 = data.frame( - team = c("Spain", "England", "France", "Germany", "Portugal", "Argentina", "Netherlands", "Brazil", - "Belgium", "Norway", "Switzerland", "Croatia", "Colombia", "Japan", "Morocco", "United States", - "Uruguay", "Senegal", "Sweden", "Ecuador", "Austria", "Turkey", "Canada", "Mexico", "South Korea", - "Ivory Coast", "Algeria", "Australia", "Czech Republic", "Scotland", "Paraguay", "Egypt", - "Bosnia and Herzegovina", "DR Congo", "Ghana", "Tunisia", "Iran", "Cape Verde", "Uzbekistan", - "Panama", "Haiti", "New Zealand", "Saudi Arabia", "Curaçao", "South Africa", "Iraq", "Qatar", "Jordan"), - win = c(14462, 12426, 12365, 11246, 8909, 8240, 5576, 4720, 2992, 2602, 2083, 1373, 1303, 1274, 990, 954, - 945, 945, 886, 752, 657, 651, 616, 601, 481, 281, 250, 222, 212, 206, 143, 121, 113, 71, 70, 59, 36, - 31, 29, 26, 24, 18, 12, 11, 7, 6, 2, 1)/1e5 -) +fifa2026 = c(Spain = 14462, England = 12426, France = 12365, Germany = 11246, Portugal = 8909, Argentina = 8240, + Netherlands = 5576, Brazil = 4720, Belgium = 2992, Norway = 2602, Switzerland = 2083, Croatia = 1373, + Colombia = 1303, Japan = 1274, Morocco = 990, `United States` = 954, Uruguay = 945, Senegal = 945, + Sweden = 886, Ecuador = 752, Austria = 657, Turkey = 651, Canada = 616, Mexico = 601, `South Korea` = 481, + `Ivory Coast` = 281, Algeria = 250, Australia = 222, `Czech Republic` = 212, Scotland = 206, Paraguay = 143, + Egypt = 121, `Bosnia and Herzegovina` = 113, `DR Congo` = 71, Ghana = 70, Tunisia = 59, Iran = 36, + `Cape Verde` = 31, Uzbekistan = 29, Panama = 26, Haiti = 24, `New Zealand` = 18, + `Saudi Arabia` = 12, Curaçao = 11, `South Africa` = 7, Iraq = 6, Qatar = 2, Jordan = 1) / 1e5 library("tinyplot") tinyplot( x = 1:48, - y = fifa2026$win, + y = fifa2026, type = "barplot", xlab = NA, ylab = NA, @@ -26,7 +23,7 @@ tinyplot( text( 1:48, -0.001, - labels = fifa2026$team, + labels = names(fifa2026), adj = c(1, 1.15), cex = 0.5, srt = 45,