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.9.0.2
pkgdown: 2.1.3
pkgdown_sha: ~
last_built: 2026-05-26T19:00:25+0000
last_built: 2026-05-30T22:06:26+0000
urls:
reference: https://grantmcdermott.com/tinyplot/man
article: https://grantmcdermott.com/tinyplot/vignettes
62 changes: 42 additions & 20 deletions vignettes/gallery.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,30 @@ 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-by-iris.R){target='_blank'}"
#| file: "gallery_figs/points-by-iris.R"
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/points-iris-boring.R){target='_blank'}"
#| file: "gallery_figs/points-iris-boring.R"
```


```{r}
#| lightbox:
#| group: r-graph
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/points-by-facet-iris.R){target='_blank'}"
#| file: "gallery_figs/points-by-facet-iris.R"
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/points-iris-better.R){target='_blank'}"
#| file: "gallery_figs/points-iris-better.R"
```

```{r}
#| lightbox:
#| group: r-graph
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/hist-by-iris.R){target='_blank'}"
#| file: "gallery_figs/hist-by-iris.R"
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/chull-penguins.R){target='_blank'}"
#| file: "gallery_figs/chull-penguins.R"
```

```{r}
#| lightbox:
#| group: r-graph
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/boxplot-by-penguins.R){target='_blank'}"
#| file: "gallery_figs/boxplot-by-penguins.R"
```

```{r}
Expand All @@ -50,8 +58,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/spineplot-titanic.R){target='_blank'}"
#| file: "gallery_figs/spineplot-titanic.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/direct-labels-aq.R){target='_blank'}"
#| file: "gallery_figs/direct-labels-aq.R"
```

```{r}
Expand All @@ -64,36 +79,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/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/hist-by-penguins.R){target='_blank'}"
#| file: "gallery_figs/hist-by-penguins.R"
```

```{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/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/polygons.R){target='_blank'}"
#| file: "gallery_figs/polygons.R"
#| 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"
```

```{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/errorbar-mtcars.R){target='_blank'}"
#| file: "gallery_figs/errorbar-mtcars.R"
```

```{r}
#| lightbox:
#| group: r-graph
#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/boxplot-by-penguins.R){target='_blank'}"
#| file: "gallery_figs/boxplot-by-penguins.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}
Expand All @@ -120,8 +135,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/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/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/polygon-valentine.R){target='_blank'}"
#| file: "gallery_figs/polygon-valentine.R"
```

:::
7 changes: 6 additions & 1 deletion vignettes/gallery_figs/add-ablines.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
library("tinyplot")

tinyplot(mpg ~ hp | cyl, facet = "by", data = mtcars)
tinyplot(mpg ~ hp | cyl, facet = "by", data = mtcars,
legend = FALSE,
theme = "classic",
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)
18 changes: 13 additions & 5 deletions vignettes/gallery_figs/add-points-rug-faithful.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
library("tinyplot")
tinyplot(eruptions ~ waiting, data = faithful, type = "lm",
theme = "tufte", palette = c("darkcyan"))
tinyplot_add(type = "p", pch = 21, col = "white", fill = 0.3, cex = 1.5)
tinyplot_add(type = type_rug(jitter = TRUE, amount = 0.3))
tinyplot_add(type = type_rug(jitter = TRUE, amount = 0.1, side = 2))

plt(eruptions ~ waiting, data = faithful,
xlab = "Eruption time (min)",
ylab = "Waiting time to next eruption (min)",
main = "Eruptions of Old Faithful",
cap = "Rug(s) = Relative density\nShaded region = LOESS fit",
type = "n",
theme = "nber"
)
plt_add(type = "loess")
plt_add(type = "p", pch = 21, col = "white", fill = 0.3, cex = 1.5)
plt_add(type = type_rug(jitter = TRUE, amount = 0.3))
plt_add(type = type_rug(jitter = TRUE, amount = 0.1, side = 2))
5 changes: 4 additions & 1 deletion vignettes/gallery_figs/boxplot-by-penguins.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ plt(
type = type_boxplot(boxwex = 0.6, staplewex = 0, outline = FALSE),
lty = 1,
flip = TRUE, yaxl = ",",
grid = TRUE
main = "Penguins in boxplot form",
sub = "Also using a different theme",
theme = "ipsum"
)
plt_add(type = 'jitter', alpha = 0.5)
2 changes: 2 additions & 0 deletions vignettes/gallery_figs/bubble-penguins.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ with(
col = 'white', fill = 0.5, pch = 21,
legend = list(labeller = ","),
type = "p",
main = "Palmer penguins",
cap = "Source: Gorman et al. (2014)",
theme = "clean2"
)
)
11 changes: 11 additions & 0 deletions vignettes/gallery_figs/chull-penguins.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library("tinyplot")

plt(
body_mass ~ bill_len | species, penguins,
yaxl = ',',
main = 'A convex hull of penguins',
sub = 'Species stick together',
theme = 'web',
legend = 'bottom!'
)
plt_add(type = 'chull', fill = 0.1, col = NA)
8 changes: 6 additions & 2 deletions vignettes/gallery_figs/density-part-shading.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ x_hi = seq(1.64, 5, length.out = 100)

tinyplot(x = -5:5,
type = type_function(dnorm),
xlab = "X", ylab = "Density",
main = "Standard normal distribution with 10% shaded region.")
xlab = "x",
ylab =expression(f(x) == frac(1, sigma * sqrt(2 * pi)) ~ e^{frac(-(x - mu)^2, 2 * sigma^2)}), "Density",
main = expression(Standard~normal~distribution: X %~% N(mu, sigma^2)),
cap = "Shaded regions denotes top/bottom 10%",
theme = "dynamic"
)

tinyplot_add(
x = x_lo,
Expand Down
3 changes: 2 additions & 1 deletion vignettes/gallery_figs/direct-labels-aq.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ tinyplot(
type = "l",
legend = "direct",
theme = "clean2",
main = "Sometimes, direct legend labels are better"
main = "Temperatures by month",
sub = "Sometimes, direct legend labels are better"
)
6 changes: 5 additions & 1 deletion vignettes/gallery_figs/errorbar-mtcars.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ tinyplot(
est ~ term, data = coefs,
ymin = lwr, ymax = upr,
type = "errorbar",
xlab = NA, ylab = "Estimate",
flip = TRUE,
draw = abline(v = 0, lty = 2, col = "grey50"),
theme = "classic"
main = "Coefficient plot",
sub = "Determinants of fuel efficiency",
cap = expression(Model: mpg == beta[0] + beta[1] %.% wt + beta[2] %.% am + beta[3] %.% wt %.% am),
theme = "socviz"
)
11 changes: 0 additions & 11 deletions vignettes/gallery_figs/hist-by-iris.R

This file was deleted.

14 changes: 14 additions & 0 deletions vignettes/gallery_figs/hist-by-penguins.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library("tinyplot")

pal = c("darkorange","purple","cyan4")

plt(
~flipper_len | species,
data = penguins,
type = "hist",
breaks = 30,
theme = "bw",
palette = pal,
main = "Histogram of flipper length",
sub = "Grouped by species"
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ tinyplot(
palette = "dark",
pch = 16,
grid = TRUE,
frame = FALSE
frame = FALSE,
main = "A more exciting scatterplot"
)
6 changes: 6 additions & 0 deletions vignettes/gallery_figs/points-iris-boring.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(tinyplot)

tinyplot(
Sepal.Length ~ Petal.Length, iris,
main = "A boring scatterplot"
)
20 changes: 20 additions & 0 deletions vignettes/gallery_figs/points-quakes-hershey.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
library(tinyplot)

plt(
lat ~ long | depth, data = quakes,
main = "Earthquakes off Fiji",
xlab = "Longitutde",
ylab = "Latitude",
cap = "Data courtesy of the Harvard PRIM-H project",
palette = "mako",
# custom ephemeral theme
theme = list(
"dynamic",
bty = "n",
bg = "#E0D9D2",# "#F7F3EF",
cex = 1.2, cex.main = 1.5, cex.lab = 1.2,
col = "#3D3532",
family = "HersheyScript",
grid = TRUE, grid.col = "gray95"
)
)
14 changes: 14 additions & 0 deletions vignettes/gallery_figs/polygon-valentine.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library(tinyplot)

i = seq(0, 2*pi, by = 0.01)
x = 16*sin(i)^3
y = 13*cos(i) - 5*cos(2*i) - 2*cos(3*i) - cos(4*i)

plt(
x, y,
type = "polygon",
col = "red", fill = adjustcolor("firebrick", 0.8),
xlab = NA, ylab = NA,
main = "Be my tinyplot Valentine!",
theme = list("void", family = "HersheyScript", adj.main = 0.5, cex.main = 3)
)
3 changes: 2 additions & 1 deletion vignettes/gallery_figs/polygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ library("tinyplot")
plt(
x = 1:9,
y = c(2,1,2,1,NA,2,1,2,1),
type = type_polygon(density = c(10, 20))
type = type_polygon(density = c(10, 20)),
theme = 'dynamic'
)
1 change: 0 additions & 1 deletion vignettes/gallery_figs/ridge-aq.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
library("tinyplot")
tinytheme("ridge2")

aq = transform(
airquality,
Expand Down
8 changes: 6 additions & 2 deletions vignettes/gallery_figs/spineplot-titanic.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ library(tinyplot)
ttnc = as.data.frame(Titanic)
tinyplot(
Survived ~ Sex | Class,
facet = "by", data = ttnc,
facet = "by", facet.args = list(nrow = 1),
legend = FALSE,
data = ttnc,
type = type_spineplot(weights = ttnc$Freq),
palette = "Dark 2", facet.args = list(nrow = 1), axes = "t"
theme = "void", axes = "t",
main = "Who survived the Titanic disaster?",
sub = "Frequencies by boarding class and sex"
)
Loading