Description Usage Arguments Details Examples
The GGPLOT2 version of the layout(). This mimics the layout() function in R base, to acheive a similar result in ggplots. Notice that argument legend.pos
doesn't work properly for other options now.
1 2 |
... |
The names of all the ggplot2 objects you created |
plotlist |
or you can put all those objects into this list, or you can leave this list as NULL. |
mat |
The arrangement matrix similar in layout() |
widths |
The widths of your arrangments similar in layout() |
heights |
The heights of you arrangements similar to layout() |
legend.pos |
If you want to use a single shared legend for all plots, then you need to set this parameter to other values. Currently support "bottom" and "right" two options. Currently none of them turned to be not working except the default. |
legend.ratio |
The ratio of the panel your shared legends will occupy |
The Shared lengeds are only available by re-setting the legend.pos paramenter.
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 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.