Multiple plot function
From: http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
library(ggplot2)
multiplot(p1, p2, p3, p4, cols=2)
# 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.
#
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
library(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# If layout is NULL, then use 'cols' to determine layout
if (is.null(layout)) {
# Make the panel
# ncol: Number of columns of plots
# nrow: Number of rows needed, calculated from # of cols
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots==1) {
print(plots[[1]])
} else {
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
# Make each plot, in the correct location
for (i in 1:numPlots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
Multiple plot function的更多相关文章
- The plot Function in matlab
from http://pundit.pratt.duke.edu/wiki/MATLAB:Plotting The plot Function The plot function is used t ...
- OPEN CASCADE Multiple Variable Function
OPEN CASCADE Multiple Variable Function eryar@163.com Abstract. Multiple variable function with grad ...
- matlab 画图
先前讲解了简单绘图方法: http://www.cnblogs.com/youxin/p/3859923.html x = 0:pi/100:2*pi; y = sin(x); plot(x,y)下面 ...
- matlab安装和入门
下载iso镜像: ISO镜像下载地址链接: http://pan.baidu.com/s/1i31bu5J 密码: obo1 单独破解文件下载链接: http://pan.baidu.com/s/1c ...
- R语言中的回归诊断-- car包
如何判断我们的线性回归模型是正确的? 1.回归诊断的基本方法opar<-par(no.readOnly=TRUE) fit <- lm(weight ~ height, data = wo ...
- [PyData] 03 - Data Representation
Ref: http://blog.csdn.net/u013534498/article/details/51399035 如何在Python中实现这五类强大的概率分布 考虑下在mgrid上画二维概率 ...
- TCGA系列--GDCRNATools
https://github.com/Jialab-UCR/GDCRNATools GDCRNATools - An R package for downloading, organizing, an ...
- R2—《R in Nutshell》 读书笔记(连载)
R in Nutshell 前言 例子(nutshell包) 本书中的例子包括在nutshell的R包中,使用数据,需加载nutshell包 install.packages("nutshe ...
- 【R】多元线性回归
R中的线性回归函数比较简单,就是lm(),比较复杂的是对线性模型的诊断和调整.这里结合Statistical Learning和杜克大学的Data Analysis and Statistical I ...
随机推荐
- 怎么让html中 还是显示<button> 而不进行编译
toTXT(str) { var RexStr = /\<|\>|\"|\'|\&| | /g str = str.replace(RexStr, ...
- Qt 滚动窗口类
{ QScrollArea *scrollArea = new QScrollArea(this); scrollArea->setFrameStyle(); scrollArea->se ...
- Rhino学习教程——1.5
图形面板 图形面板是Rhino为了方便用户操作设置的一个区域,默认提供了“属性”.“图层”.“说明”3个面板(我自定义过了,新增了一个“显示”功能 ). trip:如果要打开更多的图版,可以点击图形面 ...
- myBatis简学
mybatis使用: ①拷贝相关mybits ②编写对象关系映射,一般都是实体类名+Mapper.xml的格式 ③编写mybits配置文件: a)配置环境 b)配置映射文件地址 ④编写对象操作方法: ...
- java第五次笔记
- 转:LRU算法
LRU是Least Recently Used的缩写,即最近最少使用页面置换算法,是为虚拟页式存储管理服务的,是根据页面调入内存后的使用情况进行决策了.由于无法预测各页面将来的使用情况,只能利用“最近 ...
- Windows下PyMC安装
先安装Anaconda2 然后conda install -c https://conda.binstar.org/pymc pymc
- javascript Base64转码解码
javascript 使用btoa和atob来进行Base64转码和解码 $scope.checkAddCookie = function() { var expireDate = new Date( ...
- c#@三种作用
以前只知道@在C#中为了写文件路径的\不要加转义符而在前面加上@标识符,没想到@还有其他的作用 1.忽略转义字符例如string fileName = "D:\\文本文件\\text.txt ...
- pypyodbc 的坑
1, 你要先确认你自己的office的版本, 你要安装access dabase engine. 但是 sb 微软的驱动 32位的不让装, 64位的也不让装, 吐槽微软100次---MS个大SX. 最 ...