plot_in_png: Write a ggplot Object to PNG File

View source: R/dev-utils.R

plot_in_pngR Documentation

Write a ggplot Object to PNG File

Description

Renders a ggplot object to a PNG file using ragg for high-quality output.

Usage

plot_in_png(
  ggobj = NULL,
  code = NULL,
  width,
  height,
  res = 200,
  units = "in",
  pointsize = 11,
  scaling = 1,
  path = NULL
)

Arguments

ggobj

A ggplot object to render

width

Numeric, width of the output image

height

Numeric, height of the output image

res

Numeric, resolution in DPI (default 200)

units

Character, units for width and height ("in", "cm", "mm", "px") (default "in")

pointsize

Integer, The default pointsize of the device in pt

scaling

scaling factor to apply

path

Character, output file path. If NULL, a temporary file is created (default NULL)

Value

Character, the path to the created PNG file

Examples

plot_in_png(
  code = {
    barplot(1:10)
  },
  width = 5,
  height = 4,
  res = 72,
  units = "in"
)

officer documentation built on Dec. 4, 2025, 9:08 a.m.