R/multiplot.R

Defines functions multiplot

Documented in multiplot

##########################################################
##Drawmultiple scatter plots
#last update: 05/21/2012
#
#Adopted from: http://wiki.stdout.org/rcookbook/Graphs/Multiple%20graphs%20on%20one%20page%20%28ggplot2%29/
################################################################



multiplot <- function(..., plotlist=NULL, cols) {
    #pdf("scatterplots.pdf")
    require(grid)

    # Make a list from the ... arguments and plotlist
    plots <- c(list(...), plotlist)

    numPlots = length(plots)

    # Make the panel
    plotCols = cols                          # Number of columns of plots
    plotRows = ceiling(numPlots/plotCols) # Number of rows needed, calculated from # of cols

    # Set up the page
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
    vplayout <- function(x, y)
        viewport(layout.pos.row = x, layout.pos.col = y)

    # Make each plot, in the correct location
    for (i in 1:numPlots) {
        curRow = ceiling(i/plotCols)
        curCol = (i-1) %% plotCols + 1
        print(plots[[i]], vp = vplayout(curRow, curCol ))
    }
   #ggsave("scatterplots.png", width=10, height=10, dpi=300)
   #dev.off()

}

Try the DeconRNASeq package in your browser

Any scripts or data that you put into this service are public.

DeconRNASeq documentation built on Nov. 8, 2020, 7:51 p.m.