Title: | Graphics Cropping Tool |
---|---|
Description: | A device closing function which is able to crop graphics (e.g., PDF, PNG files) on Unix-like operating systems with the required underlying command-line tools installed. |
Authors: | Marius Hofert [aut, cre] |
Maintainer: | Marius Hofert <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 0.0-3 |
Built: | 2024-11-20 05:20:27 UTC |
Source: | https://github.com/cran/crop |
dev.off.crop()
calls dev.off()
to close the
plotting device and then crops the produced graphic. This works on
Unix-like systems if the right underlying Unix tools are installed and
found (see below).
dev.off.crop(file = NULL, warn = TRUE, ...)
dev.off.crop(file = NULL, warn = TRUE, ...)
file |
An output file name including extension. |
warn |
A |
... |
Additional arguments passed to |
Supported file extensions are .ps
(epstool
), .eps
(epstool
), .pdf
(pdfcrop
),
.png
(mogrify
) if the underlying
tools (given in parentheses) are installed and found. If they are not
installed or found or if the wrong operating system is used, simply
dev.off()
is called (and thus no cropping is done).
invisible()
.
Marius Hofert
dev.off()
for closing a device.
## Example data x <- 1:10 y <- rev(x) ## PS postscript(file = (file <- "crop.ps")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.ps") # clean-up ## EPS setEPS() # or use onefile = FALSE, horizontal = FALSE, paper = "special" in postscript() postscript(file = (file <- "crop.eps")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.eps") # clean-up ## PDF pdf(file = (file <- "crop.pdf")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.pdf") # clean-up ## PNG with white background png(filename = (file <- "crop.png")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.png") # clean-up ## PNG with transparent background ## Not doable by the underlying 'mogrify' (only cropped vertically, not horizontally) if(FALSE) { png(filename = (file <- "crop.png"), bg = "transparent") plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) }
## Example data x <- 1:10 y <- rev(x) ## PS postscript(file = (file <- "crop.ps")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.ps") # clean-up ## EPS setEPS() # or use onefile = FALSE, horizontal = FALSE, paper = "special" in postscript() postscript(file = (file <- "crop.eps")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.eps") # clean-up ## PDF pdf(file = (file <- "crop.pdf")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.pdf") # clean-up ## PNG with white background png(filename = (file <- "crop.png")) plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) file.remove("crop.png") # clean-up ## PNG with transparent background ## Not doable by the underlying 'mogrify' (only cropped vertically, not horizontally) if(FALSE) { png(filename = (file <- "crop.png"), bg = "transparent") plot(x, y, xlab = "x", ylab = "y") dev.off.crop(file = file) }