17

I've created a lattice plot with three panels. I can control the font size for the axis and tick labels, but I haven't been able to figure out how to increase the font size of the strip labels. Here's a concrete example:

# See below for the fake data to run this code
library(lattice)
barchart(choice ~ yes+no+not.app|group, data=data, 
         stack=TRUE, col=c("green","red","blue"), 
         xlim=c(0,100), layout=c(3,1),
         scales=list(cex=c(1.4,1.4), alternating=3),
         xlab=list(label="Percent of Respondents", fontsize=20), 
         main="")

Here's the graph this code produces. Note how all the fonts are nice and big except for the strip labels ("Group 1", "Group 2", "Group 3"). I've been fishing around R-help and Stack Overflow, but haven't been able to work this one out. Does anyone know the magic incantation?

enter image description here

data = structure(list(choice = c("Choice 1", "Choice 1", "Choice 1", 
"Choice 2", "Choice 2", "Choice 2", "Choice 3", "Choice 3", "Choice 3", 
"Choice 4", "Choice 4", "Choice 4"), group = c("Group 1", "Group 2", 
"Group 3", "Group 1", "Group 2", "Group 3", "Group 1", "Group 2", 
"Group 3", "Group 1", "Group 2", "Group 3"), yes = c(23.53, 20.47, 
22.94, 16.51, 16.54, 16.51, 9.68, 13.39, 10.4, 24.48, 29.92, 
25.54), no = c(41.37, 37.01, 40.52, 48.39, 40.94, 46.94, 55.22, 
44.09, 53.06, 40.42, 27.56, 37.92), not.app = c(35.1, 42.52, 
36.54, 35.1, 42.52, 36.54, 35.1, 42.52, 36.54, 35.1, 42.52, 36.54
)), .Names = c("choice", "group", "yes", "no", "not.app"), row.names = c(NA, 
12L), class = "data.frame")
eipi10
  • 81,881
  • 20
  • 176
  • 248
  • It should probably be noted that in lattice, "panel" refers to what is inside the plot area(s), while 'strips' and 'labels' are generally outside the plot area(s). – IRTFM Nov 07 '13 at 21:30
  • Just saw your comment and have updated the title and text. – eipi10 May 09 '14 at 15:40

1 Answers1

25

Try this (good work on supplying an example):

barchart(choice ~ yes+no+not.app|group, data=data, 
     par.strip.text=list(cex=2),
     stack=TRUE, col=c("green","red","blue"), 
     xlim=c(0,100), layout=c(3,1),
     scales=list(cex=c(1.4,1.4), alternating=3),
     xlab=list(label="Percent of Respondents", fontsize=20), 
     main="")

To see more about how to manage the strip features type : ?strip.default There are other levers to throw in strip.custom. Also see the latticeExtra package that has the capacity to put strips on the sides with useOuterStrips.

IRTFM
  • 240,863
  • 19
  • 328
  • 451
  • 2
    Ah, the magic word is `strip`. I kept messing around with variations of `panel.this`, `panel.that` and wasn't getting anywhere. Thanks! – eipi10 Oct 04 '12 at 02:02
  • The panel functions deal with what appears within the boxes. So, yes, the magic word is "strip". And I confess it took me a couple of years to learn this magic word. – IRTFM Oct 04 '12 at 02:05
  • A small comment: while I was able to globally specify all similar commands (e.g., `par.ylab.text = list(cex = 0.8)`) via `trellis.par.set()`, this did not work for `par.strip.text=list(cex=2)`. It has to be specified right in the plot command. Any ideas why this is the case? – deca Feb 05 '18 at 15:17
  • Look at the return from ‘trellis.par.get()’ and read that function’s help page. – IRTFM Feb 05 '18 at 23:21