Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion altdoc/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions vignettes/gallery.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -90,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-meat.R){target='_blank'}"
#| file: "gallery_figs/barplot-meat.R"
```

```{r}
#| lightbox:
#| group: r-graph
Expand Down
31 changes: 31 additions & 0 deletions vignettes/gallery_figs/barplot-fifa2026.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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,
type = "barplot",
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("broadsheet", mar = c(4, 0.1, 0.6, 0.6), col.default = "#2A9D8F")
)
text(
1:48,
-0.001,
labels = names(fifa2026),
adj = c(1, 1.15),
cex = 0.5,
srt = 45,
xpd = TRUE
)
25 changes: 25 additions & 0 deletions vignettes/gallery_figs/barplot-meat.R
Original file line number Diff line number Diff line change
@@ -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)"
)
21 changes: 21 additions & 0 deletions vignettes/gallery_figs/line-eustockmarkets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 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)),
value = as.numeric(EuStockMarkets)
)

library("tinyplot")
tinyplot(
value ~ time | market,
data = eu,
facet = "by", legend = FALSE,
type = "l",
theme = "clean2",
main = "EU stock markets performance",
xlab = NA, ylab = NA,
yaxl = ","
)
50 changes: 50 additions & 0 deletions vignettes/gallery_figs/line-ipcc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 = "socviz",
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]",
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")
}
)