Learn R Programming

manureshed (version 0.1.2)

save_plot: Save Plot

Description

Save ggplot object to file with publication-quality settings

Usage

save_plot(
  plot,
  file_path,
  width = 11,
  height = 6,
  dpi = 300,
  units = "in",
  device = NULL
)

Value

Character. Path to saved file

Arguments

plot

ggplot object. Plot to save

file_path

Character. Output file path

width

Numeric. Plot width in inches (default: 11)

height

Numeric. Plot height in inches (default: 6)

dpi

Numeric. Resolution in dots per inch (default: 300)

units

Character. Units for width and height (default: "in")

device

Character. Output device (auto-detected from file extension)

Examples

Run this code
# \donttest{
# Create a simple plot for demonstration
library(ggplot2)
p <- ggplot(mtcars, aes(x = mpg, y = hp)) + geom_point()

# Save with default settings (300 DPI, 11x6 inches)
save_plot(p, file.path(tempdir(), "test_plot.png"))

# Save with custom dimensions for presentation
save_plot(p, file.path(tempdir(), "presentation_plot.png"), width = 16, height = 9)

# Save as PDF for publication
save_plot(p, file.path(tempdir(), "publication_figure.pdf"), width = 8, height = 6)
# }

Run the code above in your browser using DataLab