| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/plot.R |
| 3 |
\name{plot_crop} |
| 4 |
\alias{plot_crop} |
| 5 |
\title{Crop a plot (remove the edges) using PDFCrop or ImageMagick} |
| 6 |
\usage{ |
| 7 |
plot_crop(x, quiet = TRUE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{Filename of the plot.} |
| 11 |
|
| 12 |
\item{quiet}{Whether to suppress standard output from the command.} |
| 13 |
} |
| 14 |
\value{ |
| 15 |
The original filename. |
| 16 |
} |
| 17 |
\description{ |
| 18 |
The program \command{pdfcrop} (often shipped with a LaTeX distribution) is |
| 19 |
executed on a PDF plot file, and |
| 20 |
\code{magick::\link[magick:transform]{image_trim}()} is executed for other |
| 21 |
types of plot files. |
| 22 |
} |
| 23 |
\details{ |
| 24 |
The program \command{pdfcrop} can crop the extra white margins when the plot |
| 25 |
format is PDF, to make better use of the space in the output document, |
| 26 |
otherwise we often have to struggle with \code{graphics::\link{par}()} to set |
| 27 |
appropriate margins. Note \command{pdfcrop} often comes with a LaTeX |
| 28 |
distribution such as TinyTeX, MiKTeX, or TeX Live, and you may not need to |
| 29 |
install it separately (use \code{Sys.which('pdfcrop')} to check it; if it not |
| 30 |
empty, you are able to use it). Note that \command{pdfcrop} depends on |
| 31 |
GhostScript. You can check if GhostScript is installed via |
| 32 |
\code{tools::find_gs_cmd()}. |
| 33 |
} |
| 34 |
\references{ |
| 35 |
PDFCrop: \url{https://www.ctan.org/pkg/pdfcrop}. If you use |
| 36 |
TinyTeX, you may install \command{pdfcrop} with |
| 37 |
\code{tinytex::tlmgr_install('pdfcrop')}. |
| 38 |
} |