[R] Spacing and margins in plot
Earl F. Glynn
efg at stowers-institute.org
Thu Sep 1 16:17:16 CEST 2005
This technote explains the margin area (mar) and how to modify it to control
white space around a graphic:
http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm
When you have multiple figures on a graphic, you may also want to learn to
control the outer margin area (oma), which is also explained.
AFAIK, the only way to get the axis label "closer" to the axis is to
suppress the actual axis labels and use the mtext command to display
alternative text where you want it. For example, look at the blue text in
Figure 2B (at the above link) that is between the axis label and the axis.
This blue text is at line=2, when the axis labels are at line=3.
efg
Bioinformatics
Stowers Institute
"Jamieson Cobleigh" <cobleigh at gmail.com> wrote in message
news:7f50836c050901060555b9289d at mail.gmail.com...
> If I use the following command to plot points:
>
> plot(c(1,2,2,3,3,3), type="p", pch=20, ylab="Y Label", xlab="X Label",
xaxt="n")
>
> there is a large amount of space between the label "X Label" and the
> actual x-axis. If I change the xaxt="n" to xaxt="s", the label "X
> Label" don't move at all. Is there a way to get the label "X Label"
> closer to the x-axis when xaxt="n"?
>
> The plot I am generating is going to be included in a paper I am
> writing. I can cause the plot to be saved in a PDF file by doing the
> following:
>
> pdf("foo.pdf", width=5.5, height=4.25, onefile=FALSE)
>
> plot(c(1,2,2,3,3,3), type="p", pch=20, ylab="Y Label", xlab="X Label",
xaxt="n")
>
> dev.off();
>
> In the resulting file, there is a lot of whitespace around the graph,
> particularly between the top line of the plot area and the top of the
> page. Since I am including these plots in a paper, I want them to be
> as large as possible and not take up any extra space. Is there a way
> to get R to draw a plot that goes all the way to the margins of the
> print area?
More information about the R-help
mailing list