R pdf set margin

11,278

Within pdf(), change the width and height arguments (https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/pdf.html). The default values are 7 and 7, which is likely why there is extra space on your page.

Share:
11,278
RockScience
Author by

RockScience

Updated on July 20, 2022

Comments

  • RockScience
    RockScience almost 2 years

    I am trying to set the figure margin for a pdf generated with R. Using mar, I can reduce the plot margins. However the resulted plot is still a square in the middle of the page instead of using all the space. How can I change that?

    pdf(file = "test.pdf", paper="a4r")
    par(mar=c(0,0,0,0)+0.1)
    plot(1:10,1:10)
    dev.off()
    

    Thank you!

    enter image description here