我需要帮助与晶格bwplot。我制作了我的多面板图,并将它们放在同一个窗口中。
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))我想做的是,在每个图中包含相同的图边距外的文本,字母A表示第一个图,B表示第二个图,这有助于在我的报告中回忆起这个图(例如,图1A和图1)。
有人有有用的建议吗?
发布于 2014-09-02 00:01:47
网格是在网格图形中构建的。像这样添加图形标签的最直接方法是使用grid.text。在两次print()调用之后,添加
library(grid)
grid.text("A", .1, .95, gp=gpar(fontsize=20))
grid.text("B", .1, .45, gp=gpar(fontsize=20))您可能需要调整这些值以获得所需的位置

https://stackoverflow.com/questions/25609317
复制相似问题