[R] Lattice: distance of Y-axis label from plot

Peter Ehlers ehlers at ucalgary.ca
Fri Jul 22 19:02:31 CEST 2011


On 2011-07-22 07:33, marcel wrote:
> Basic question: I looked around quite a bit, still having a little trouble
> manipulating the distance between the Y-axis label and the plot. In this
> case, I would like to move the Y axis title closer to the plot.
>
>
> # Data
> tC<- textConnection("
> Time Type1 Type2 Type3
> 1.3 .50 .10 .40
> 4.5 .45 .20 .35
> 5.2 .40 .30 .30
> ")
>
> data1<- read.table(header=TRUE, tC)
> data2<- data.frame(Time=rep(data1$Time, 3), stack(data1[,2:4]))
> close.connection(tC)
> rm(tC)
>
> #PLOT 1 lattice bar plot
> require(lattice)
> plot1<-xyplot(values ~ Time, ylab=list(label="Move this title closer to
> plot", fontsize=9), scales=list(y=list(relation="free", rot=0, cex=0.7), x =
> list(draw = FALSE)), group=ind, data=data2, stack=TRUE, horizontal=FALSE,
> panel=panel.barchart, box.width=0.1, axes=FALSE, ylim=c(0.03,0.98),
> xlim=c(-0.2, 6.25), main="", xlab="")
>
> #position X1,Y1, X2,Y2
> print(plot1, position=c(-0.018,0.221,0.741,0.466))

Lattice has many parameters that can be modified. Have a look at
help(trellis.par.get). For your purpose, look at either

  trellis.par.get()$layout.widths

or

  lattice.options()$layout.widths

You'll want to modify the ylab.axis.padding setting. The easiest
way is to add a par.settings argument to your plot definition:

  xyplot(...,
    par.settings = list(
          layout.widths = list(ylab.axis.padding = 0.5)))


Peter Ehlers

>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Lattice-distance-of-Y-axis-label-from-plot-tp3686855p3686855.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.



More information about the R-help mailing list