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
87 changes: 87 additions & 0 deletions vignettes/gallery.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

:::
8 changes: 8 additions & 0 deletions vignettes/gallery_figs/gallery_04.R
Original file line number Diff line number Diff line change
@@ -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"
)
7 changes: 7 additions & 0 deletions vignettes/gallery_figs/gallery_05.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
library(tinyplot)
tinytheme("ipsum")

tinyplot(Sepal.Width ~ Petal.Width | Species,
data = iris,
type = "lm")
tinyplot_add(type = "p", alpha = .2)
16 changes: 16 additions & 0 deletions vignettes/gallery_figs/gallery_06.R
Original file line number Diff line number Diff line change
@@ -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)
)
)
9 changes: 9 additions & 0 deletions vignettes/gallery_figs/gallery_07.R
Original file line number Diff line number Diff line change
@@ -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"
)
14 changes: 14 additions & 0 deletions vignettes/gallery_figs/gallery_08.R
Original file line number Diff line number Diff line change
@@ -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")
)
5 changes: 5 additions & 0 deletions vignettes/gallery_figs/gallery_09.R
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 7 additions & 0 deletions vignettes/gallery_figs/gallery_10.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
library("tinyplot")
tinytheme("bw")
tinyplot(
~Petal.Width | Species,
type = "histogram",
data = iris
)
8 changes: 8 additions & 0 deletions vignettes/gallery_figs/gallery_11.R
Original file line number Diff line number Diff line change
@@ -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)
)
6 changes: 6 additions & 0 deletions vignettes/gallery_figs/gallery_12.R
Original file line number Diff line number Diff line change
@@ -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)))
8 changes: 8 additions & 0 deletions vignettes/gallery_figs/gallery_13.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library("tinyplot")

tinyplot(mpg ~ hp | factor(cyl),
data = mtcars,
type = type_text(
labels = row.names(mtcars),
font = 1,
adj = 0))
5 changes: 5 additions & 0 deletions vignettes/gallery_figs/gallery_14.R
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions vignettes/gallery_figs/gallery_15.R
Original file line number Diff line number Diff line change
@@ -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())