YuLab-SMU / ggbreak

:broken_heart: An implementation of scale functions for setting axis breaks of a 'gg' plot.
https://www.frontiersin.org/articles/10.3389/fgene.2021.774846
127 stars 4 forks source link

theme(plot.margin) no longer works in ggplot2 when also use "scale_y_break" #61

Open caitlin-jeffrey opened 11 months ago

caitlin-jeffrey commented 11 months ago

thanks for this package, i love being able to use it to put in an axis break! wanted to report what seems like a bug that someone else had posted without a resolution on stack overflow: https://stackoverflow.com/questions/75871080/plot-margin-fails-after-scale-y-cut

once you include a line of code for scale_y_break(), the command for margins stops working. below you can try commenting out the scale_y_break() line to reproduce this issue.

library(ggplot2)
library(ggbreak)
ggplot(mtcars, aes(x=as.factor(cyl), y=mpg)) + 
    geom_boxplot(fill="slateblue", alpha=0.2) + 
    xlab("cyl")+
    theme(plot.margin = margin(t = 2, l = 3, r = 2, b = 2, "cm"))+
    scale_y_break(c(1, 7))

thanks!

Nitin123-4 commented 3 months ago

Same issue I am also facing.

PetraTschuchnig commented 3 weeks ago

I have the same problem and would be very grateful for help.

drdna commented 3 days ago

not only does plot margin no longer work but coord_cartesian(clip = "off) also does not work with ggbreak