[R] Several lattice plots on one page

Marcus Drescher drescher at tum.de
Mon Nov 8 19:19:28 CET 2010


Dear all,

I am trying (!!!) to generate pdfs that have 8 plots on one page:


df = data.frame(
	day = c(1,2,3,4),
	var1 = c(1,2,3,4),
	var2 = c(100,200,300,4000),
	var3 = c(10,20,300,40000),
	var4 = c(100000,20000,30000,4000),
	var5 = c(10,20,30,40),
	var6 = c(0.001,0.002,0.003,0.004),
	var7 = c(123,223,123,412),
	var8 = c(213,123,234,435),
	all = as.factor(c(1,1,1,1)))

pdf("test1.pdf", width=20, heigh=27, paper="a4") 
    print(plot(groupedData(var1 ~ day | all, data = df), main = "var1", xlab="", ylab=""), split=c(1,1,2,4), more=TRUE)
    print(plot(groupedData(var2 ~ day | all, data = df), main = "var2", xlab="", ylab=""), split=c(1,2,2,4), more=TRUE)
    print(plot(groupedData(var3 ~ day | all, data = df), main = "var3", xlab="", ylab=""), split=c(1,3,2,4), more=TRUE)
    print(plot(groupedData(var4 ~ day | all, data = df), main = "var4", xlab="", ylab=""), split=c(1,4,2,4), more=TRUE)
    print(plot(groupedData(var5 ~ day | all, data = df), main = "var5", xlab="", ylab=""), split=c(2,1,2,4), more=TRUE)
    print(plot(groupedData(var6 ~ day | all, data = df), main = "var6", xlab="", ylab=""), split=c(2,2,2,4), more=TRUE)
    print(plot(groupedData(var7 ~ day | all, data = df), main = "var7", xlab="", ylab=""), split=c(2,3,2,4), more=TRUE)
    print(plot(groupedData(var8 ~ day | all, data = df), main = "var8", xlab="", ylab=""), split=c(2,4,2,4))
dev.off()


My problem is that the separate plots all have different sizes. (Some are tall, but very small, or the other way around. The target is to have equally tall and wide graphs. (The variables have different scales. Grouping does not work.)

Optimally, the plots would use the complete pdf page.

Any ideas how to adjust height and width?

Best 
Marcus



More information about the R-help mailing list