How can I remove the white margins in ggsave?
My question is exactly the same as Remove white space (i.e., margins) ggplot2 in R. However, the answer there isn\'t ideal
If you're using Unix or Mac OS, another option when the various margin options aren't trimming enough is to use the pdfcrop
command available within Unix through R
's ability to invoke system commands:
# after saving image, run pdfcrop
system2(command = "pdfcrop",
args = c("name_or_path_of_file_before_crop.pdf",
"name_or_path_of_file_after_crop.pdf")
)
For more, see: https://robjhyndman.com/hyndsight/crop-r-figures/