1

I need help with lattice bwplot. I made my multipanel plots and I put them in the same window.

library(lattice)
attach(mtcars)

gear.f<-factor(gear,levels=c(3,4,5), labels=c("3gears","4gears","5gears"))
cyl.f <-factor(cyl,levels=c(4,6,8), labels=c("4cyl","6cyl","8cyl"))

plot1 <- bwplot(cyl.f~mpg|gear.f, ylab="Cylinders", xlab="Miles per Gallon", main="Mileage by Cylinders and Gears", layout=(c(1,3)))

plot2 <- xyplot(mpg~wt|cyl.f*gear.f, main="Scatterplots by Cylinders and Gears", ylab="Miles per Gallon", xlab="Car Weight")

print(plot1, position=c(0, 0.5, 1, 1), more=TRUE)
print(plot2, position=c(0, 0, 1, 0.5))

What I would like to do, it's to include same text outside the plot margin in each plot, letter A for the first plot and B for the second useful to recall this plot in my report (e.g. Fig. 1A and Fig. 1).

Someone has useful suggestions?

David Arenburg
  • 91,361
  • 17
  • 137
  • 196

1 Answers1

2

Lattice is build in grid graphics. The most direct way to add figure labels like that is with grid.text. After your two print() calls, add

library(grid)
grid.text("A", .1, .95, gp=gpar(fontsize=20))
grid.text("B", .1, .45, gp=gpar(fontsize=20))

You may need to tweak those values to get the placement how you like it

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295