cf_outputFigure: Output figures

View source: R/plotting.R

cf_outputFigureR Documentation

Output figures

Description

Handle paginate automatically, save asynchronously with future

Usage

cf_outputFigure(
  pl,
  filename = NULL,
  width = 16,
  height = 10,
  scale = 1,
  units = c("cm", "mm", "in")[1],
  dpi = 300,
  limitsize = TRUE,
  device = NULL,
  heightrel = NULL,
  FLAGFuture = TRUE,
  FLAGoverwrite = TRUE,
  ...
)

Arguments

pl

plot like ggplot, potentially created with facet_grid_paginate or list of ggplots

filename, width, height, scale, units, dpi, limitsize, device, ...

see [ggplot2::ggsave()]

FLAGFuture

Export asynchronously with the future-package

Details

# importFrom ggplot2 plot_dev parse_dpi plot_dim

Value

nothing

Examples

.tempdir = tempdir()
.currentdir <- getwd()
setwd(.tempdir)

library(conveniencefunctions)

# -------------------------------------------------------------------------#
# 1 Paginate ----
# -------------------------------------------------------------------------#
# Large facetted plot
pl <- ggplot(diamonds) +
  geom_point(aes(carat, price), alpha = 0.1) +
  facet_grid_paginate(color ~ clarity, ncol = 3, nrow = 3, page = 4)

# Basic stuff
n_pages(pl)
getPaginateInfo(pl)
plotlist <- cf_applyPaginate(pl)
length(plotlist)

# Asynchronous outputting
cf_outputFigure(pl, filename = "wup.png")
cf_outputFigure(pl, filename = "wupwup.pdf")

# Go to the files
try(system("nautilus .", wait = FALSE))

# Exit ----
setwd(.currentdir)
future::plan("sequential")

dlill/conveniencefunctions documentation built on Sept. 30, 2022, 4:40 a.m.