[R] X-Axis Label Overwritten By TickMark Values

2005-10-01 Thread Paul Roebuck
Can someone tell me how to fix the left margin of plot region
such that the tick values don't overwrite the x-axis label?
I haven't been able to set the correct par option to fix this...

TIA


grdev - function(...) {
get(getOption(device))(...)
}

plotFixMe - function(spectrum, ...) {
saved.par - par(las = 1, tcl = 0.3)
on.exit(par(saved.par))

plot(spectrum,
 type = l,
 col  = blue,
 xlab = ,
 ylab = ,
 ...)
title(main = x-axis label overwritten by tick values,
  xlab = Index,
  ylab = Intensity)
}

grdev()
plotFixMe(rnorm(50)*2, ylim = c(0, 5))

--
SIGSIG -- signature too long (core dumped)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] X-Axis Label Overwritten By TickMark Values

2005-10-01 Thread Marc Schwartz
On Sat, 2005-10-01 at 06:07 -0500, Paul Roebuck wrote:
 Can someone tell me how to fix the left margin of plot region
 such that the tick values don't overwrite the x-axis label?
 I haven't been able to set the correct par option to fix this...
 
 TIA
 
 
 grdev - function(...) {
 get(getOption(device))(...)
 }
 
 plotFixMe - function(spectrum, ...) {
 saved.par - par(las = 1, tcl = 0.3)
 on.exit(par(saved.par))
 
 plot(spectrum,
  type = l,
  col  = blue,
  xlab = ,
  ylab = ,
  ...)
 title(main = x-axis label overwritten by tick values,
   xlab = Index,
   ylab = Intensity)
 }
 
 grdev()
 plotFixMe(rnorm(50)*2, ylim = c(0, 5))


Paul,

This is the Y axis label, not the X axis.

Set par(mar) prior to creating the plot to increase the left hand
margin space and then use mtext() rather than title() to move the Y axis
label further left by using the 'line' argument.


grdev - function(...) {
get(getOption(device))(...)
}

plotFixMe - function(spectrum, ...) {
saved.par - par(las = 1, tcl = 0.3)
on.exit(par(saved.par))

par(mar = c(5, 6, 4, 2))

plot(spectrum,
 type = l,
 col  = blue,
 xlab = ,
 ylab = ,
 ...)

title(main = x-axis label overwritten by tick values)

mtext(1, text = Index, line = 3)
mtext(2, text = Intensity, line = 5, las = 3)
}

grdev()
plotFixMe(rnorm(50)*2, ylim = c(0, 5))


See ?par and ?mtext for more information.

BTW, I would not use 'tcl = 0.3' which, as a positive value, places the
tick marks themselves within the plot region. That's contrary to typical
guidance, since the tick marks get lost in this plot and more
importantly, can overwrite data points in certain plot types.

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html