Home > Mobile >  plot_grid function removes axis breaks from ggbreak in plots
plot_grid function removes axis breaks from ggbreak in plots

Time:01-07

I'm struggling with a problem: I created two volcano plots in ggplot2, but due to the fact that I had one outlier point in both plot, I need to add y axis break for better visualization. The problem arises when I WANT TO plot both in the same page using plot_grid from cowplot::, because it visualizes the original plot without the breaks that I set.

 p<- c1 %>%
     ggplot(aes(x = avg_log2FC,
                y = -log10(p_val_adj),
                fill = gene_type,    
                size = gene_type,
                alpha = gene_type))   
     geom_point(shape = 21, # Specify shape and colour as fixed local parameters    
                colour = "black")   
     geom_hline(yintercept = 0,
                linetype = "dashed")   
     scale_fill_manual(values = cols)   
     scale_size_manual(values = sizes)   
     scale_alpha_manual(values = alphas)   
     scale_x_continuous(limits=c(-1.5,1.5), breaks=seq(-1.5,1.5,0.5))   
     scale_y_continuous(limits=c(0,110),breaks=seq(0,110,25)) 
     labs(title = "Gene expression",
          x = "log2(fold change)",
          y = "-log10(adjusted P-value)",
          colour = "Expression \nchange")  
     theme_bw()   # Select theme with a white background  
     theme(panel.border = element_rect(colour = "black", fill = NA, size= 0.5),    
           panel.grid.minor = element_blank(),
           panel.grid.major = element_blank()) 
   p1 <- p   scale_y_break(breaks = c(30, 100))
   p1

p plot without breaks: enter image description here

and p1 plot with breaks: enter image description here

The same I did for the second plot. But this is the result using plot_grid(p1,p3, ncol = 2)

enter image description here

Can you help me understanding if I'm doing something wrong? or it is just a limitation of the package?

CodePudding user response:

OP, it seems in that ggbreak is not compatible with functions that arrange multiple plots, as enter image description here

  • Related