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
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ where the formatting is also better._
- Added support for "bubble" scatter plots, allowing for point size scaling via
an appropriate `cex` argument (e.g., a continuous variable from your dataset).
Simultaneously enables dual-legend support for combined size + color mappings.
The updated `?type_points` helpfile contains several examples.
The updated `?type_points` documentation contains several examples.
(#433 @grantmcdermott)
- Improved horizontal legend spacing, as well as multicolumn legend support. A
new example in the "Tips & tricks" vignettes demonstrates the latter.
Expand Down Expand Up @@ -48,6 +48,11 @@ where the formatting is also better._
correct parameters and spacing. (#475, #481 @grantmcdermott)
- Custom `cex` theme settings are now reset correctly. (#482 @grantmcdermott)

### Documentation

- @grantmcdermott's _useR! 2025_ **tinyplot** presentation has been added to the
website as a standalone
[vignette](https://grantmcdermott.com/tinyplot/vignettes/useR2025/useR2025.html).

### Internals

Expand Down
11 changes: 8 additions & 3 deletions vignettes/useR2025/_extensions/grantmcdermott/clean/clean.scss
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,21 @@ $selection-bg: #26351c !default;
.reveal table th,
.reveal table td {
border: none; /* Remove internal row lines */
padding: .23em; /* Adjust padding as needed */
padding: .23em .46em; /* Adjust padding as needed */
text-align: left; /* Adjust text alignment as needed */
font-weight: lighter; /* Lighter font weight for main table text */
}

/* Adds a bottom border to the table header row for distinction */
/* Add top border to first row and bottom border to last row only */
.reveal table thead th,
.reveal .slides table tr:first-child td {
border-top: 2px solid #D3D3D3;
}

.reveal table thead th,
.reveal .slides table tr:last-child td,
.reveal .slides table {
border-bottom: 2px solid #D3D3D3; /* Dark grey color for the bottom border */
border-bottom: 2px solid #D3D3D3;
}

/* Make column headers bold */
Expand Down
Binary file modified vignettes/useR2025/img/rgraphics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/useR2025/img/rgraphics2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 44 additions & 35 deletions vignettes/useR2025/useR2025.qmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
---
# title: tinyplot
# subtitle: Lightweight extension of the base R graphics system
# format: clean-revealjs
title: "<br/><br/><br/>"
subtitle: Lightweight extension of the base R graphics system
format:
clean-revealjs:
title-slide-attributes:
data-background-image: "img/background.png"
# clean-revealjs:
# # logo: img/logo.svg
# title-slide-attributes:
# data-background-image: "img/background.png"
data-background-size: contain
execute:
echo: true
author:
Expand Down Expand Up @@ -270,19 +265,24 @@ But going beyond the defaults is often (much) more work that I want to do.

### R has two low-level graphics systems

::: {.r-stack}
![Note: Adapted from @murrell2023updates.](img/rgraphics.png)
![](img/rgraphics.png)

![Note: Adapted from @murrell2023updates.](img/rgraphics2.png){.fragment}
:::
## grid vs graphics (redux) {visibility="uncounted" auto-animate=true}

### R has two low-level graphics systems

![](img/rgraphics2.png)

## grid vs graphics (redux) {visibility="uncounted" auto-animate=true}

### R has two low-level graphics systems

![](img/rgraphics2.png)

::: {.fragment}
**tinyplot** goals:

1. Make base R graphics more user-friendly.
2. Improved feature parity vs. grid-based 📦s like **ggplot2** and **lattice**.
:::
2. Improved feature parity vs. grid-based 📦s like **ggplot2** and **lattice**.

## Origin story 🤝

Expand Down Expand Up @@ -523,19 +523,25 @@ plt(
## tinyplot API
### types

All tinyplot types can be passed as either a:
tinyplot types can be passed as either a _string_ or _function_:

- _string_ (`"p"`, `"density`, `"lm"`, ...), or
- _function_ (`type_points()`, `type_density()`, `type_lm()`, ...)
| | | | | |
|-----|:----|:----|:----|:----|
| _string_ | `"p"` | `"density"` | `"lm"` | `"<name>"` |
| _function_ | `type_points()` | `type_density()` | `type_lm()` | `type_<name>()` |

In general, the functional equivalents are denoted `type_*()` and support direct argument passing for customization, e.g.
\

::: {.fragment}
The function variants all take the form `type_<name>` and support type-specific
argument passing for customization, e.g.

```{r}
?type_lm
args(type_lm)
# ?type_lm # full documentation
str(type_lm) # available args
```
::: {.callout-note}
Custom args can also be passed through `plt(...)`, so long as there isn't a top-level clash.

P.S. Type args can also be passed via `plt(...)` _if_ there's no top-level clash.
:::

## tinyplot API
Expand Down Expand Up @@ -821,8 +827,8 @@ plt(
#| fig-width: 6
#| fig-asp: 1

mod = lm(body_mass ~ species + sex,
data = penguins)
mod = lm(weight ~ 0 + Time + Diet,
data = ChickWeight)
coefs = data.frame(
names(coef(mod)),
coef(mod),
Expand Down Expand Up @@ -898,6 +904,11 @@ plt(Month ~ Temp | Temp,
)
```

```{r}
#| include: false
tinytheme()
```

# Conclusions

## Advantages of tinyplot {#sec-adv}
Expand All @@ -920,7 +931,7 @@ For the longer version: [[tinyplot pros]{.button}](#sec-pros)
- Custom layout
- Missing features

For the longer version: [[tinyplot pros]{.button}](#sec-cons)
For the longer version: [[tinyplot cons]{.button}](#sec-cons)

## Acknowledgements

Expand Down Expand Up @@ -966,17 +977,17 @@ Many other contributors, feedback providers, and a sources of inspiration.
::: {#refs}
:::

# Bonus: Tinyplot pros {#sec-pros}
# Bonus: Tinyplot pros {#sec-pros visibility="uncounted"}

## Concise
## Concise {visibility="uncounted"}

### The formula API gives bang for buck

![](img/briggs.png)

_P.S. Thanks to Ryan for letting me use this screenshot._

## Concise
## Concise {visibility="uncounted"}

### The formula API gives bang for buck

Expand Down Expand Up @@ -1018,7 +1029,7 @@ plt(

_(That's about 1/3 fewer characters.)_

## Concise
## Concise {visibility="uncounted"}

### Concision is even starker vs. vanilla base plot

Expand All @@ -1044,7 +1055,7 @@ Adapted from @viechtbauer2025tinyplot.

::::

## Lightweight
## Lightweight {visibility="uncounted"}

### Base R only

Expand All @@ -1063,9 +1074,9 @@ Very fast to install and play with in webR / WebAssembly. ([Try it!](https://web
[[Back to main]{.button}](#sec-adv)


# Bonus: Tinyplot cons {#sec-cons}
# Bonus: Tinyplot cons {#sec-cons visibility="uncounted"}

## Layering gotchas
## Layering gotchas {visibility="uncounted"}

### Scaling is fixed by the first layer

Expand All @@ -1078,7 +1089,7 @@ plt_add(type = "lm")
This is a limitation of **graphics** "canvas" logic. (Workarounds: Change layer order, or use `x/ylim`.)
:::

## Layering gotchas
## Layering gotchas {visibility="uncounted"}

### Can't combine `file` with `plt_add` (yet)

Expand All @@ -1096,18 +1107,16 @@ I'm hoping to provide a native solution in the future, but workarounds for now:
- Open/close the appropriate graphics device manually, e.g. `png("myplot.png"); plt(...); plt_add(...); dev.off() `
:::

## Missing features
## Missing features {visibility="uncounted"}

I hope that I have convinced you that **tinyplot** covers a _lot_ of ground.

- The API should also be very stable. I expect few (if any) breaking changes from here on out.

::: {.fragment}
Still, **tinyplot** is a relatively young project and there are some features and plot types that we don't support (yet). Some things coming down the pike:

- bubble plots ([#433](https://github.com/grantmcdermott/tinyplot/pull/433))
- dodged elements ([#406](https://github.com/grantmcdermott/tinyplot/issues/406))
- maps ([#210](https://github.com/grantmcdermott/tinyplot/issues/210))
:::

[[Back to main]{.button}](#sec-disadv)