[R] Difficulty labeling plot axis when "mar" and "oma" are set

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Mar 4 08:03:05 CET 2008


The axis labels go in the margins -- you left no space for the margins 
when you asked for mar = c(0,0,0,0) and hence the labels were clipped to 
invisibility.

It you want to write in the outer margins you have to use mtext() or 
title() with outer=TRUE.

Looking at the pictures in 'An Introduction to R' may help you understand 
the various margins.

On Mon, 3 Mar 2008, eite2335 wrote:

>
> Dear all,
>
> Though labeling the x and y axis in the plot command seems to be straight
> forward, I can not get it to work if I do the following:
>
>
> ## Creating example data
>
> edata <- c(1,2,1,2)
>
> edata <- matrix(edata, 2, 2, byrow = T)
>
> colnames(edata) <- c("a", "b")
>
> edata <- data.frame(edata)
>
>
>
> ## plot data
>
>
> par(mfrow<- c(1,2))
>
> plot(edata$a, edata$b, xlab = "a", ylab = "b")   ## Note that the x and y
> axis are labled
>
> plot(edata$a, edata$b, xlab = "a", ylab = "b")
>
>
> par(mfrow=c(1,2), mar = c(0,0,0,0), oma = c(3,3,3,3))
>
> plot(edata$a, edata$b, xlab = "a", ylab = "b")   ## Note that the x and y
> axis are not labled though x and ylab are set
>
> plot(edata$a, edata$b, xlab = "a", ylab = "b", yaxt = "n")
>
>
>
>
> Does anybody has an idea why this is
>
> Thanks for the help
>
> --
> View this message in context: http://www.nabble.com/Difficulty-labeling-plot-axis-when-%22mar%22-and-%22oma%22-are-set-tp15818482p15818482.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list