Saptarshi Guha
2008-Apr-03 16:57 UTC
[R] Question on spacing around plot and box in lattice
Hello, How can i increase the padding between the axis and the data region(box just containing the figure) in xyplot? An example: new <- function(x){ if(x<0){ return(x^2) }else{ return(x) } } x <- seq(-1,1,length.out=100) y <- sapply(x,new) sc=list() sc$alternating=0 sc$tck=0 xyplot(y~x,type='l', aspect=0.05, scales=sc, col='black', xlab='', ylab='' ) When plotted on quartz(Mac) device, there is very little padding between the bottom of the curve and the lower horizontal axis and between the maximum values of the curve and the upper horizontal axis. How can i increase the padding - top,bottom,left and right? Thanks in advance for your time. Regards Saptarshi Saptarshi Guha | saptarshi.guha@gmail.com | http://www.stat.purdue.edu/~sguha [[alternative HTML version deleted]]
Deepayan Sarkar
2008-Apr-03 22:11 UTC
[R] Question on spacing around plot and box in lattice
On 4/3/08, Saptarshi Guha <saptarshi.guha at gmail.com> wrote:> Hello, > How can i increase the padding between the axis and the data > region(box just containing the figure) in xyplot? > > An example: > new <- function(x){ if(x<0){ return(x^2) }else{ return(x) } } > x <- seq(-1,1,length.out=100) > y <- sapply(x,new) > sc=list() > sc$alternating=0 > sc$tck=0 > > xyplot(y~x,type='l', > aspect=0.05, > scales=sc, > col='black', > xlab='', > ylab='' > ) > When plotted on quartz(Mac) device, there is very little padding > between the bottom of the curve and the lower horizontal axis and > between the maximum values of the curve and the upper horizontal axis. > How can i increase the padding - top,bottom,left and right?The default padding is taken from lattice.getOption("axis.padding"), and you could change it to, say, 20% using xyplot(y~x,aspect=0.05,scales=sc, lattice.options = list(axis.padding = list(numeric = 0.2))) For finer control, write your own prepanel function. -Deepayan