save_ggplot: save_ggplot

View source: R/Coxmos_plot_functions.R

save_ggplotR Documentation

save_ggplot

Description

Allows to save 'ggplot2' objects in .tiff format based on an specific resolution.

Usage

save_ggplot(
  plot,
  folder,
  name = "plot",
  wide = TRUE,
  quality = "4K",
  dpi = 80,
  format = "tiff",
  custom = NULL
)

Arguments

plot

'ggplot2' object. Object to plot and save.

folder

Character. Folder path as character type.

name

Character. File name.

wide

Logical. If TRUE, widescreen format (16:9) is used, in other case (4:3) format.

quality

Character. One of: "HD", "FHD", "2K", "4K", "8K"

dpi

Numeric. DPI value for the image.

format

Device to use. Can either be a device function (e.g. png), or one of "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only).

custom

Numeric vector. Custom size of the image. Numeric vector of width and height.

Value

Generate a plot image in the specific folder or working directory.

Author(s)

Pedro Salguero Garcia. Maintainer: pedsalga@upv.edu.es

Examples


if(requireNamespace("ggplot2", quietly = TRUE)){
library(ggplot2)
data(iris)
g <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species))
g <- g + geom_point(size = 4)
file_path <- tempfile(fileext = ".png")
ggsave(file_path, plot = g)
unlink(file_path) # Eliminar el archivo temporal
}


Coxmos documentation built on April 4, 2025, 12:20 a.m.