Skip to content

Difficulty labeling plot axis when "mar" and "oma" are set

2 messages · eite2335, Brian Ripley

#
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
#
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: