thomasp85 / patchwork

The Composer of ggplots
https://patchwork.data-imaginist.com
Other
2.47k stars 163 forks source link

Title gets lost when adding 2 patchwork-ggplot objects #104

Closed efratushava closed 5 years ago

efratushava commented 5 years ago

Hello,

My code looks like this: `plots <- lapply(c("RNF2","EMX1"),function(x) { plot_grna <- lapply(c("rep1","rep2","rep3"), function(rep){ sample <-rep_num[grep(rep,rep_num[grep(x,rep_num$Group),c("Group")]),c("Sample")] path <- all_files_G2A[grep(paste0(sample,".ES.bed_files"),all_files_G2A)] ggplot() + geom_logo(as.character(data$motif),method = 'p') + theme_logo() + ylab(paste("Rep.",stringi::stri_sub(rep,-1,-1)))+ theme(legend.position="none", axis.title.y = element_text(angle = 0, vjust=0.5,size=20)) })

-----here I plot the inner loop plot, with its own title plot_grna[[1]]+plot_grna[[2]]+plot_grna[[3]]+plot_layout(ncol = 1)+ plot_annotation(title = paste(x,"gRNA")) })

---- plots[[1]]+plots[[2]]+plot_layout(ncol = 2)-didn't work somehow plots[[1]] | plots[[2]]`

plots[[1]] looks like this: image

and plot[[1]] | plot[[2]] looks:

efratushava commented 5 years ago

plot_zoom_png

As you can see, the title gets lost when adding the two plots together.

What can I do?

steveharoz commented 5 years ago

Hi @efratushava

It'd be helpful if you could format your code.

If you type this:

``` Your code here ```

You'll see this:

Your code here