Last data update: 2014.03.03

R: Creates a grid of subplots
subplotsR Documentation

Creates a grid of subplots

Description

Creates a grid of subplots in the current figure. If arguments nrow and ncol are given a nrow-by-ncol grid of subplots are created. If only argument n is given then a r-by-s grid is created where |r-s| <= 1, i.e. a square or almost a square of subplots is created. If n and nrow is given then a grid with nrow rows and at least n subplots are created. Similar if n and ncol is given. The argument byrow specifies if the order of the subplots should be rowwise (byrow=TRUE) or columnwise.

Usage

## Default S3 method:
subplots(n=1, nrow=NULL, ncol=NULL, byrow=TRUE, ...)

Arguments

n

If given, the minimum number of subplots.

nrow

If given, the number of rows the grid of subplots should contain.

ncol

If given, the number of columns the grid of subplots should contain.

byrow

If TRUE, the panels are ordered row by row in the grid, otherwise column by column.

...

Not used.

Value

Returns the matrix containing the order of plots.

Author(s)

Henrik Bengtsson

See Also

layout and layout.show().

Examples

   subplots(nrow=2, ncol=3)  # 2-by-3 grid of subplots
   subplots(n=6, nrow=2)     # 2-by-3 grid of subplots
   subplots(n=5, ncol=2)     # 3-by-2 grid of subplots
   subplots(1)               # (Reset) to a 1-by-1 grid of subplots
   subplots(2)               # 1-by-2 grid of subplots
   subplots(3)               # 2-by-2 grid of subplots
   l <- subplots(8)          # 3-by-3 grid of subplots
   layout.show(length(l))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(R.utils)
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.20.0 (2016-02-17) successfully loaded. See ?R.oo for help.

Attaching package: 'R.oo'

The following objects are masked from 'package:methods':

    getClasses, getMethods

The following objects are masked from 'package:base':

    attach, detach, gc, load, save

R.utils v2.3.0 (2016-04-13) successfully loaded. See ?R.utils for help.

Attaching package: 'R.utils'

The following object is masked from 'package:utils':

    timestamp

The following objects are masked from 'package:base':

    cat, commandArgs, getOption, inherits, isOpen, parse, warnings

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/R.utils/subplots.Rd_%03d_medium.png", width=480, height=480)
> ### Name: subplots
> ### Title: Creates a grid of subplots
> ### Aliases: subplots.default subplots
> 
> ### ** Examples
> 
>    subplots(nrow=2, ncol=3)  # 2-by-3 grid of subplots
>    subplots(n=6, nrow=2)     # 2-by-3 grid of subplots
>    subplots(n=5, ncol=2)     # 3-by-2 grid of subplots
>    subplots(1)               # (Reset) to a 1-by-1 grid of subplots
>    subplots(2)               # 1-by-2 grid of subplots
>    subplots(3)               # 2-by-2 grid of subplots
>    l <- subplots(8)          # 3-by-3 grid of subplots
>    layout.show(length(l))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>