diff --git a/altdoc/pkgdown.yml b/altdoc/pkgdown.yml index 1961883b2..69d3f06f0 100644 --- a/altdoc/pkgdown.yml +++ b/altdoc/pkgdown.yml @@ -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 diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index 0f43a30a4..487ce38a3 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -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} @@ -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} @@ -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} @@ -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" ``` ::: diff --git a/vignettes/gallery_figs/add-ablines.R b/vignettes/gallery_figs/add-ablines.R index 19bcb4153..16f29303f 100644 --- a/vignettes/gallery_figs/add-ablines.R +++ b/vignettes/gallery_figs/add-ablines.R @@ -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) diff --git a/vignettes/gallery_figs/add-points-rug-faithful.R b/vignettes/gallery_figs/add-points-rug-faithful.R index cb42e91d5..588d205bc 100644 --- a/vignettes/gallery_figs/add-points-rug-faithful.R +++ b/vignettes/gallery_figs/add-points-rug-faithful.R @@ -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)) diff --git a/vignettes/gallery_figs/boxplot-by-penguins.R b/vignettes/gallery_figs/boxplot-by-penguins.R index ba3b6e822..ce63e3aa8 100644 --- a/vignettes/gallery_figs/boxplot-by-penguins.R +++ b/vignettes/gallery_figs/boxplot-by-penguins.R @@ -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) diff --git a/vignettes/gallery_figs/bubble-penguins.R b/vignettes/gallery_figs/bubble-penguins.R index 0f8992123..72a8b72ba 100644 --- a/vignettes/gallery_figs/bubble-penguins.R +++ b/vignettes/gallery_figs/bubble-penguins.R @@ -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" ) ) diff --git a/vignettes/gallery_figs/chull-penguins.R b/vignettes/gallery_figs/chull-penguins.R new file mode 100644 index 000000000..4c360862d --- /dev/null +++ b/vignettes/gallery_figs/chull-penguins.R @@ -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) diff --git a/vignettes/gallery_figs/density-part-shading.R b/vignettes/gallery_figs/density-part-shading.R index f849156e8..96d3948be 100644 --- a/vignettes/gallery_figs/density-part-shading.R +++ b/vignettes/gallery_figs/density-part-shading.R @@ -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, diff --git a/vignettes/gallery_figs/direct-labels-aq.R b/vignettes/gallery_figs/direct-labels-aq.R index 1437c8c26..93af62782 100644 --- a/vignettes/gallery_figs/direct-labels-aq.R +++ b/vignettes/gallery_figs/direct-labels-aq.R @@ -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" ) diff --git a/vignettes/gallery_figs/errorbar-mtcars.R b/vignettes/gallery_figs/errorbar-mtcars.R index 66a11f058..4711a2b7d 100644 --- a/vignettes/gallery_figs/errorbar-mtcars.R +++ b/vignettes/gallery_figs/errorbar-mtcars.R @@ -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" ) diff --git a/vignettes/gallery_figs/hist-by-iris.R b/vignettes/gallery_figs/hist-by-iris.R deleted file mode 100644 index e01066586..000000000 --- a/vignettes/gallery_figs/hist-by-iris.R +++ /dev/null @@ -1,11 +0,0 @@ -library("tinyplot") - -tinyplot( - ~Petal.Length | Species, - data = iris, - type = "histogram", - breaks = 30, - main = "Histogram of petal lengths", - sub = "Grouped by species", - theme = "bw" -) \ No newline at end of file diff --git a/vignettes/gallery_figs/hist-by-penguins.R b/vignettes/gallery_figs/hist-by-penguins.R new file mode 100644 index 000000000..beefec520 --- /dev/null +++ b/vignettes/gallery_figs/hist-by-penguins.R @@ -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" +) \ No newline at end of file diff --git a/vignettes/gallery_figs/points-by-iris.R b/vignettes/gallery_figs/points-iris-better.R similarity index 70% rename from vignettes/gallery_figs/points-by-iris.R rename to vignettes/gallery_figs/points-iris-better.R index 158a6c116..23e9d18af 100644 --- a/vignettes/gallery_figs/points-by-iris.R +++ b/vignettes/gallery_figs/points-iris-better.R @@ -6,5 +6,6 @@ tinyplot( palette = "dark", pch = 16, grid = TRUE, - frame = FALSE + frame = FALSE, + main = "A more exciting scatterplot" ) diff --git a/vignettes/gallery_figs/points-iris-boring.R b/vignettes/gallery_figs/points-iris-boring.R new file mode 100644 index 000000000..8e3c3180c --- /dev/null +++ b/vignettes/gallery_figs/points-iris-boring.R @@ -0,0 +1,6 @@ +library(tinyplot) + +tinyplot( + Sepal.Length ~ Petal.Length, iris, + main = "A boring scatterplot" +) diff --git a/vignettes/gallery_figs/points-quakes-hershey.R b/vignettes/gallery_figs/points-quakes-hershey.R new file mode 100644 index 000000000..95008f9f7 --- /dev/null +++ b/vignettes/gallery_figs/points-quakes-hershey.R @@ -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" + ) +) diff --git a/vignettes/gallery_figs/polygon-valentine.R b/vignettes/gallery_figs/polygon-valentine.R new file mode 100644 index 000000000..5eaf52c71 --- /dev/null +++ b/vignettes/gallery_figs/polygon-valentine.R @@ -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) +) diff --git a/vignettes/gallery_figs/polygons.R b/vignettes/gallery_figs/polygons.R index b520e7b82..0369ce73a 100644 --- a/vignettes/gallery_figs/polygons.R +++ b/vignettes/gallery_figs/polygons.R @@ -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' ) diff --git a/vignettes/gallery_figs/ridge-aq.R b/vignettes/gallery_figs/ridge-aq.R index f060e2f20..83f411cef 100644 --- a/vignettes/gallery_figs/ridge-aq.R +++ b/vignettes/gallery_figs/ridge-aq.R @@ -1,5 +1,4 @@ library("tinyplot") -tinytheme("ridge2") aq = transform( airquality, diff --git a/vignettes/gallery_figs/spineplot-titanic.R b/vignettes/gallery_figs/spineplot-titanic.R index 8f6625faf..9963cda5d 100644 --- a/vignettes/gallery_figs/spineplot-titanic.R +++ b/vignettes/gallery_figs/spineplot-titanic.R @@ -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" )