Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elipousson/papersize
🖨️ A R package for sizing plots and files for paper.
https://github.com/elipousson/papersize
Last synced: 27 days ago
JSON representation
🖨️ A R package for sizing plots and files for paper.
- Host: GitHub
- URL: https://github.com/elipousson/papersize
- Owner: elipousson
- License: other
- Created: 2022-12-16T17:55:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T15:27:13.000Z (7 months ago)
- Last Synced: 2024-04-02T16:33:57.403Z (7 months ago)
- Language: R
- Homepage: https://elipousson.github.io/papersize/
- Size: 7.49 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png"
)
```# papersize
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Project Status: WIP -- Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Codecov test coverage](https://codecov.io/gh/elipousson/papersize/branch/main/graph/badge.svg)](https://app.codecov.io/gh/elipousson/papersize?branch=main)The goal of papersize is to provide you with convenience functions extending grid, ggplot2, and patchwork to help in sizing plots and files for printing to paper, postcards, playing cards, and other physical media.
## Installation
You can install the development version of papersize like so:
``` r
# pak::pkg_install("elipousson/papersize")
```## Example
```{r setup}
library(papersize)
```papersize includes data on standard paper sizes including sizes for papers (ANSI, ISO, and other standards), photo prints, postcards, and playing cards.
```{r get_page}
get_paper("Letter")get_paper("Letter", orientation = "landscape")
get_card("Poker")
```papersize includes plotting functions that create lists of ggplot2 plots with repeated elements that can be assembled with patchwork into page layouts for print.
For example, `plot_cards()` creates a list of Poker-card sized plots that can be tiled onto a letter-size patchwork to save and print.
```{r plot_cards}
papersize <-
plot_cards(
"Poker",
n = 8,
number = TRUE,
border = TRUE,
size = 4,
linewidth = 0.5,
text = rep(c("\U2664", "\U2661", "\U2662", "\U2667"), 2),
color = "yellow"
)papersize[[1]]
``````{r layout_cards}
page_layout(
plots = papersize,
page = "Letter",
orientation = "landscape"
)
```This more involved example uses the internal `add_card_border()` function to apply rectangular elements to the card plot:
```{r}
card <- get_card("Poker card")card_center <- card
card_center[["x"]] <- 0
card_center[["y"]] <- 0
card_offset <- card_center
card_offset[["y"]] <- 0.75card_plots <- plot_cards(
"Poker card",
fill = "white",
linetype = "solid",
color = "black",
linewidth = 0.45,
n = 8,
border = TRUE,
inset = 0
)card_plots[[1]]
``````{r}
# Add outline of image
bordered_cards <- add_card_border(
card_plots,
card = card_offset,
color = "black",
linewidth = 0.25,
linetype = "solid",
inset = c(0.2, 1)
)bordered_cards[[1]]
``````{r}
bordered_cards <- bordered_cards |>
add_card_border(
card = card_center,
color = "gray50",
linewidth = 0.25,
linetype = "solid",
inset = c(0.1, 0.1)
)bordered_cards[[1]]
```Card plots are then assembled in a page ready for export, printing, and cutting:
```{r}
card_page <- page_layout(
plots = bordered_cards,
page = "Letter",
orientation = "landscape"
)card_page[[1]]
```papersize currently has limited features but additional features are expected to include better support for multi-page layouts, control over the position of card elements, preset card formats/designs, and appropriate handling of cut-lines for DIY card printing.