码迷,mamicode.com
首页 > 编程语言 > 详细

R语言一页多图

时间:2015-08-26 21:44:40      阅读:618      评论:0      收藏:0      [点我收藏+]

标签:

require(ggplot2)
require(Cairo)
require(grid)
p = ggplot(iris,aes(x = Species,y = Sepal.Length,colour = Species))
p+geom_point()
a = p+geom_point()
b = qplot(Sepal.Length,Petal.Length,data=iris,geom="point",colour = Species)
c = qplot(Species,Sepal.Width,data=iris,geom="boxplot",fill = Species)
#创建新的画图页面
grid.newpage()
pushViewport(viewport(layout = grid.layout(2,2)))
vplayout = function(x,y)viewport(layout.pos.row = x,layout.pos.col = y)
print(a,vp = vplayout(1,1:2))
print(b,vp = vplayout(2,1))
print(c,vp = vplayout(2,2))
ggsave("test_layout.pdf",width = 8,height = 6)
dev.off()

技术分享

 

R语言一页多图

标签:

原文地址:http://www.cnblogs.com/yangk/p/4761470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!