ggplot多图叠加_简单将ggplot多个图排列在一起

这篇博客介绍了如何使用grid库来布局ggplot图形,包括创建一个名为multiplot的函数,该函数可以接受ggplot对象并按照指定的列数或者布局矩阵进行多图的排列。示例展示了如何直接使用ggplot对象以及将ggplot对象放入列表中进行两列排列的绘图。同时提到了参考资料中的CloneEvol包和boxplot.r函数。
摘要由CSDN通过智能技术生成

这里我们使用grid对ggplot的画图对象进行布局

# Multiple plot function

#

# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot

# objects)

# - cols: Number of columns in layout

# - layout: A matrix specifying the layout. If present, 'cols' is ignored.

#

# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),

# then plot 1 will go in the upper left, 2 will go in the upper right, and

# 3 will go all the way across the bottom.

# e=0.15, # extra height needed for last plot (vertical layout),

# or extra width for first plot (horizontal layout)

multiplot

layout=NULL, horizontal=FALSE, e=0.15) {

require(grid)

# Make a list from the ... arguments and plotlist

plots = c(list(...), plotlist)

numPlots = length(plots)

#message(p

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值