JPlotToTIFF: Plot to a TIFF file

View source: R/plot_to_file.R

JPlotToTIFFR Documentation

Plot to a TIFF file

Description

Writes the output of a plot to a TIFF file. If you are using ggplot, try either using JPlotToTIFF(filename, print(<plotting code>)) or else ggsave().

Usage

JPlotToTIFF(
  filename,
  plotExpr,
  width = 180,
  height = NA,
  aspectRatio = 3/2,
  units = c("mm", "cm", "px", "in"),
  tryToUseRagg = TRUE,
  type = ifelse(capabilities()["cairo"], "cairo", NULL),
  res = 72,
  onlyIfDoesntExist = FALSE,
  createDirectory = TRUE,
  ...
)

Arguments

filename

The name of the TIFF to create or overwrite. If NULL, plot output goes to the current device.

plotExpr

A function or expression which will produce the plot to be written to the file.

width

The width of the output TIFF file in units.

height

The height of the output TIFF file in units. Defaults to width / aspectRatio. If height is specified, aspectRatio will be ignored.

aspectRatio

Aspect ratio (width / height) of the output TIFF file.

units

Units of width and height.

tryToUseRagg

If TRUE (the default) and the ragg package is installed, the TIFF file will be created using agg_tiff, otherwise tiff will be used. See https://ragg.r-lib.org for more information.

type

Plotting device; passed directly to tiff. Defaults to "cairo" if that is an available device since it produces nicer looking graphics. Ignored if tryToUseRagg == TRUE and ragg is installed.

res

The nominal resolution in ppi. The value is passed in to grDevices::tiff(). Increasing the resolution will increase the size (in pixels) of the text and graph elements.

onlyIfDoesntExist

If TRUE and the output file already exists, JPlotToTIFF will do nothing.

createDirectory

If TRUE and filename is located in a directory which doesn't exist, the directory will be created.

...

Any additional arguments are passed to agg_tiff or tiff.

Value

The result of evaluating plotExpr is returned invisibly (which means it is not automatically printed).

See Also

agg_tiff, tiff


JimMcL/JUtils documentation built on Nov. 7, 2024, 11:25 a.m.