Skip to content
Prev 277702 / 398506 Next

Introducing \n's so that par.strip.text can produce multiline strips in lattice

Hi:

This worked for me - I needed to modify some of the strip labels to
improve the appearance a bit and also reduced the strip font size a
bit to accommodate the lengths of the strings. The main thing was to
change \\n to \n.

Firstly, I created a new variable called Indic as a character variable
and then did some minor surgery on three of the strings:

Indic <- as.character(imports$Indicator)
Indic[3 + 6 *(0:5)] <- "Chemicals and related\n   products imports"
Indic[4 + 6 *(0:5)] <- "Pearls, semiprecious &\nprecious stones imports"
Indic[5 + 6 *(0:5)] <- "Metaliferrous ores &\nmetal scrap imports"

# Read Indic into the imports data frame as a factor:
imports$Indic <- factor(Indic)

# Redo the plot:
barchart(X03/1000 ~ time | Indic,
         data = imports[which(imports$time != 1), ],
         horiz = FALSE,
         scales = list(x = list(rot=45, labels=paste("Mar",2007:2011))),
         par.strip.text=list(lineheight=1, lines=2, cex = 0.8))

Dennis
On Wed, Nov 16, 2011 at 11:25 PM, Ashim Kapoor <ashimkapoor at gmail.com> wrote: