ggmfrow: Simple Multiple Figure Arrangement for GGPLOT2

Description Usage Arguments See Also Examples

Description

It mimics the effect of the par(mfrow=c()) option in R base

Usage

1
ggmfrow(..., plotlist = NULL, cols)

Arguments

...

Just list all the ggplot2 objects you want to arrange in a single panel.

plotlist

Or you can put all the objects in this list.

cols

How many cols you want to show in the final panel. The rows of the grid will be determined automatically

See Also

gglayout

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library(ggplot2);library(grid)

line_data_len[1:5,]

zoom <- data.frame(xmin=c(250, 500, 1400), 
                   xmax=c(350, 600, 1500), 
                   ymin=c(0.45, 0.12, 0.06),
                   ymax=c(0.50, 0.17, 0.11),
                   Area=paste("Zoom_", 1:3, sep=""))

original <- ggplot(data=line_data_len, 
                   aes(x=stbs_duration, y=Purity))+
                   geom_line(aes(color=DataType))+
                   scale_colour_brewer(palette="Set1")+
                   scale_fill_brewer(palette="Set3")+
                     geom_rect(data=zoom,
                       aes(x=NULL, y=NULL,  #Use Null seems avoid some Problem.
                           xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
                           fill=Area))+
                             coord_cartesian(xlim=c(0, 3000), ylim=c(0,1))+
                             theme(legend.position = "none")

all_len_gg_1<- ggplot(data=line_data_len, 
                      aes(x=stbs_duration, y=Purity))+
                      scale_fill_brewer(palette="Set3")+
                      geom_rect(data=zoom, alpha=0.5,
                        aes(x=NULL, y=NULL,  #Use Null seems avoid some Problem.
                            xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
                            fill=Area))+
                              geom_line(aes(color=DataType))+
                              scale_colour_brewer(palette="Set1")+
                              coord_cartesian(xlim=c(0, 3000), ylim=c(0,1))+
                              theme(legend.position = "none")

all_len_gg_2 <- all_len_gg_1+ylab("")+
  coord_cartesian(xlim=c(5000, max(line_data_len$stbs_duration)), ylim=c(0,1))

all_zoom1 <- all_len_gg_1+
  coord_cartesian(xlim=c(zoom$xmin[1], zoom$xmax[1]), 
  ylim=c(zoom$ymin[1],zoom$ymax[1]))
all_zoom2 <- all_len_gg_1+ylab("")+
  coord_cartesian(xlim=c(zoom$xmin[2], zoom$xmax[2]), 
  ylim=c(zoom$ymin[2],zoom$ymax[2]))
all_zoom3 <- all_len_gg_1+ylab("")+
  coord_cartesian(xlim=c(zoom$xmin[3], zoom$xmax[3]), 
  ylim=c(zoom$ymin[3],zoom$ymax[3]))

gglayout(original, all_len_gg_2,all_zoom1,all_zoom2,all_zoom3,
         mat=matrix(c(1,3,1,4,2,5), nrow=2),
         legend.pos="none", legend.ratio=0.35)

ggmfrow(all_len_gg_2, all_zoom1, all_zoom3, all_zoom2, cols=2)

fzwaeustc/pcrfn documentation built on May 16, 2019, 4:06 p.m.