【发布时间】:2015-03-11 08:18:14
【问题描述】:
我使用here 中的multiplot 函数将graph<-ggplot(...) 形式的大量图表与线堆叠在一起
png(filename = "qwerty.png", width = 1024, height = 1024, units = "px",
pointsize = 11, bg = "white", res = 150)
multiplot(graph1,graph2,...., layout=matrix(c(1,2,3,4,5,6,7,8), nrow=8,
byrow=TRUE))
dev.off()
我想在第一个图表上方添加几行文本,例如,文本可能会进行复杂的编辑,例如某些字母的粗体。
我尝试使用,在multiplot前后放置它
mtext(expression(paste("only ", bold("a"), " should be bold")), 1, 1)
但我得到了错误
Error in mtext(expression(paste("only ", bold("a"), " should be bold")), :
plot.new has not been called yet`
用我的文本''as the graph'' 叠加另一个空图会更好吗?如果是这样,我该怎么做?
这些数据可用于构建图表
p1 <- ggplot((subset(mtcars, gear==4)), aes(x=mpg, y=hp)) +
geom_point() +
ggtitle("4 gears")
p2<-ggplot((subset(mtcars, gear==3)), aes(x=mpg, y=hp)) +
geom_point() +
ggtitle("3 gears")
multiplot(p1, p2, cols=2)
【问题讨论】: