diff --git a/vignettes/gallery.qmd b/vignettes/gallery.qmd index c22b0ac3..dcd3f337 100644 --- a/vignettes/gallery.qmd +++ b/vignettes/gallery.qmd @@ -38,5 +38,92 @@ Click on a plot to get the link to its code. #| group: r-graph #| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_03.R)" #| file: "gallery_figs/gallery_03.R" +#| fig-asp: .5 ``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_04.R)" +#| file: "gallery_figs/gallery_04.R" +#| fig-asp: .5 +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_05.R)" +#| file: "gallery_figs/gallery_05.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_06.R)" +#| file: "gallery_figs/gallery_06.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_07.R)" +#| file: "gallery_figs/gallery_07.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_08.R)" +#| file: "gallery_figs/gallery_08.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_09.R)" +#| file: "gallery_figs/gallery_09.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_10.R)" +#| file: "gallery_figs/gallery_10.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_11.R)" +#| file: "gallery_figs/gallery_11.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_12.R)" +#| file: "gallery_figs/gallery_12.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_13.R)" +#| file: "gallery_figs/gallery_13.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_14.R)" +#| file: "gallery_figs/gallery_14.R" +``` + +```{r} +#| lightbox: +#| group: r-graph +#| description: "[Code](https://github.com/grantmcdermott/tinyplot/blob/main/vignettes/gallery_figs/gallery_15.R)" +#| file: "gallery_figs/gallery_15.R" +``` + ::: diff --git a/vignettes/gallery_figs/gallery_04.R b/vignettes/gallery_figs/gallery_04.R new file mode 100644 index 00000000..8f6625fa --- /dev/null +++ b/vignettes/gallery_figs/gallery_04.R @@ -0,0 +1,8 @@ +library(tinyplot) +ttnc = as.data.frame(Titanic) +tinyplot( + Survived ~ Sex | Class, + facet = "by", data = ttnc, + type = type_spineplot(weights = ttnc$Freq), + palette = "Dark 2", facet.args = list(nrow = 1), axes = "t" +) diff --git a/vignettes/gallery_figs/gallery_05.R b/vignettes/gallery_figs/gallery_05.R new file mode 100644 index 00000000..e3b49712 --- /dev/null +++ b/vignettes/gallery_figs/gallery_05.R @@ -0,0 +1,7 @@ +library(tinyplot) +tinytheme("ipsum") + +tinyplot(Sepal.Width ~ Petal.Width | Species, + data = iris, + type = "lm") +tinyplot_add(type = "p", alpha = .2) \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_06.R b/vignettes/gallery_figs/gallery_06.R new file mode 100644 index 00000000..74a7c80b --- /dev/null +++ b/vignettes/gallery_figs/gallery_06.R @@ -0,0 +1,16 @@ +library(tinyplot) +tinytheme("minimal") + +# fit a model and extract coefficients +mod = lm(mpg ~ wt * factor(am), mtcars) +coefs = data.frame(names(coef(mod)), coef(mod), confint(mod)) +colnames(coefs) = c("term", "est", "lwr", "upr") + +# plot the coefficients with error bars +with( + coefs, + tinyplot( + x = term, y = est, ymin = lwr, ymax = upr, + type = type_errorbar(length = 0.1) + ) +) \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_07.R b/vignettes/gallery_figs/gallery_07.R new file mode 100644 index 00000000..e0b5c2bb --- /dev/null +++ b/vignettes/gallery_figs/gallery_07.R @@ -0,0 +1,9 @@ +library("tinyplot") + +i = 4*(0:10) + +tinyplot( + xmin = 100+i, ymin = 300+i, xmax = 150+i, ymax = 380+i, + by = i, fill = 0.2, + type = "rect" +) \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_08.R b/vignettes/gallery_figs/gallery_08.R new file mode 100644 index 00000000..7775e753 --- /dev/null +++ b/vignettes/gallery_figs/gallery_08.R @@ -0,0 +1,14 @@ +library("tinyplot") +tinytheme("ridge2") + +aq = transform( + airquality, + Month = factor(month.abb[Month], levels = month.abb[5:9]), + Month2 = factor(month.name[Month], levels = month.name[5:9]), + Late = ifelse(Day > 15, "Late", "Early") +) + +tinyplot(Month ~ Temp | Temp, + data = aq, + type = type_ridge(col = "white") +) diff --git a/vignettes/gallery_figs/gallery_09.R b/vignettes/gallery_figs/gallery_09.R new file mode 100644 index 00000000..8eb690c1 --- /dev/null +++ b/vignettes/gallery_figs/gallery_09.R @@ -0,0 +1,5 @@ +library("tinyplot") +tinyplot(eruptions ~ waiting, data = faithful, type = "lm") +tinyplot_add(type = type_rug(jitter = TRUE, amount = 0.3)) +tinyplot_add(type = type_rug(jitter = TRUE, amount = 0.1, side = 2)) +tinyplot_add(type = "p") \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_10.R b/vignettes/gallery_figs/gallery_10.R new file mode 100644 index 00000000..acc021af --- /dev/null +++ b/vignettes/gallery_figs/gallery_10.R @@ -0,0 +1,7 @@ +library("tinyplot") +tinytheme("bw") +tinyplot( + ~Petal.Width | Species, + type = "histogram", + data = iris +) \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_11.R b/vignettes/gallery_figs/gallery_11.R new file mode 100644 index 00000000..aafc04ad --- /dev/null +++ b/vignettes/gallery_figs/gallery_11.R @@ -0,0 +1,8 @@ +library("tinyplot") +tinytheme("tufte") + +tinyplot( + len ~ dose | supp, data = ToothGrowth, lty = 1, + flip = TRUE, + type = type_boxplot(boxwex = 0.6, staplewex = 0, outline = FALSE) +) \ No newline at end of file diff --git a/vignettes/gallery_figs/gallery_12.R b/vignettes/gallery_figs/gallery_12.R new file mode 100644 index 00000000..f9319383 --- /dev/null +++ b/vignettes/gallery_figs/gallery_12.R @@ -0,0 +1,6 @@ +library("tinyplot") + +tinyplot( + x = 1:9, + y = c(2,1,2,1,NA,2,1,2,1), + type = type_polygon(density = c(10, 20))) diff --git a/vignettes/gallery_figs/gallery_13.R b/vignettes/gallery_figs/gallery_13.R new file mode 100644 index 00000000..70122196 --- /dev/null +++ b/vignettes/gallery_figs/gallery_13.R @@ -0,0 +1,8 @@ +library("tinyplot") + +tinyplot(mpg ~ hp | factor(cyl), + data = mtcars, + type = type_text( + labels = row.names(mtcars), + font = 1, + adj = 0)) diff --git a/vignettes/gallery_figs/gallery_14.R b/vignettes/gallery_figs/gallery_14.R new file mode 100644 index 00000000..18535f43 --- /dev/null +++ b/vignettes/gallery_figs/gallery_14.R @@ -0,0 +1,5 @@ +library("tinyplot") + +cols = c("black", "green", "orange") +tinyplot(mpg ~ hp | factor(cyl), facet = ~ factor(cyl), data = mtcars, col = cols) +tinyplot_add(type = type_vline(v = c(100, 150, 200)), lty = 3, lwd = 3) diff --git a/vignettes/gallery_figs/gallery_15.R b/vignettes/gallery_figs/gallery_15.R new file mode 100644 index 00000000..f849156e --- /dev/null +++ b/vignettes/gallery_figs/gallery_15.R @@ -0,0 +1,21 @@ +library("tinyplot") + +x_lo = seq(-5, -1.64, length.out = 100) +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.") + +tinyplot_add( + x = x_lo, + ymin = 0, + ymax = dnorm(x_lo), + type = type_ribbon()) + +tinyplot_add( + x = x_hi, + ymin = 0, + ymax = dnorm(x_hi), + type = type_ribbon())