# [R] lattice: control size of axis title and axis labels

Jacob Wegelin jacob.wegelin at gmail.com
Sat Aug 8 18:19:39 CEST 2009

```
Was: Re: Adjusting x/y text labels for a bwplot using cex.lab

The purpose of this email is merely to explain how to control, separately,
two different text sizes on the axes in an R plot, in traditional or lattice
graphics. I did not find an explicit exposition of this, with examples, in a
quick hunt on the Web or in a couple books on R graphics.

I want to control the size separately of

(1) the title of the axis ("Important predictor" or "My outcome" or "X" or
"Y")

(2) the numbers on the axis (or text in place of numbers).

In R, the word "label" is ambiguous. The term "axis label" (e.g., in
documentation of the "las" parameter) refers to the numbers on the axis,
whereas "xlab" refers to the title of the axis.

x<-rnorm(15); y<- x^2; plot(x,y, cex.axis=1, cex.lab=2, xlab="Important
predictor", ylab="My outcome")

makes "Important predictor" and "My outcome" big, whereas

plot(x,y, cex.axis=2, cex.lab=1)

puts huge numbers on the axes. And one can control one axis at a time. For
instance,

plot(x,y, axes=F, ylab=""); axis(1, cex.axis=2)

puts huge numbers on the x axis and does not mark the y axis at all.

In lattice:

xyplot(y~x, xlab=list(label="Important predictor", cex=2))

makes "Important predictor" big, whereas

xyplot(y~x, scales=list(x=list(cex=2)) )

makes the numbers on the x axis huge. And it does not have to be numbers
along the x axis. One can put text in place of numbers, as in:

xyplot(y~x, scales=list(x=list( cex=2 , at=(-1:1) , labels=c("little", "Oh",
"big"))) )

Jake Wegelin

S Ellison wrote:
>
> You probably missed the bit in the lattice documentation which says that
> few if any of the standard par() parameters work on lattice. lattice
> uses its own system.
>
> Look at the xyplot help page and seek out the scales argument. That
> tells you that scales is a list, optionally with x and y components,
> that controls the axis appearance. The bit you probably want is the cex
> component of that.
>
> Using one of the simpler examples from ?xyplot, this looks like:
> xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
>        type = "a",
>        auto.key = list(space = "right", points = FALSE, lines = TRUE),
>        scales=list(x=list(cex=1.5))) #specifies bigger text on the
> x-axis
>
> Steve E
>
>>>> mcobb_berkeley <mccrea.cobb at gmail.com> 07/21/09 10:10 PM >>>
>
> Searched for this and found some help, but I still can't figure it out.
>
> I have trying to enlarge the x and y labels on my box plot.  I
> understand
> that you can do this using "cex.lab", but it does not seem to be working
> for
> me.  I must be adding it in the wrong spot.  Any help would be greatly
> appreciated.  Here is my code:
>
> bwplot(hr~Herd, data=telemetry, notch=T, ylab="Home Range Area (ha)",
> xlab="Herd",
> par.settings = list(plot.symbol = list(col = "black"),box.umbrella =
> list(col ="black"), box.rectangle=list(col="black")),fill="light blue")
>
> ~McCrea
> --
> View this message in context:
> 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
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> *******************************************************************
> This email and any attachments are confidential. Any use...{{dropped:8}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

--
View this message in context: http://www.nabble.com/Adjusting-x-y-text-labels-for-a-bwplot-using-cex.lab-tp24595920p24877995.html
Sent from the R help mailing list archive at Nabble.com.

```