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
131 stars 4 forks source link

A dual y-axis added #51

Closed jolehtonen closed 1 year ago

jolehtonen commented 2 years ago

Hi, I would like to use ggbreak in my plots but it draws a dual y-axis to my plots. Is there still a bug in the package? Any help is appreciated.

scale_y_continuous(breaks=seq(0, 60000, 10000)) + scale_y_break(c(20000, 50000))

Untitled-2

ZJURenyi commented 1 year ago

Found the same issue. I tried removing ylim and the second y axis was gone. I guess you might need to delete scale_y_continuous

ClaudiuPapasteri commented 1 year ago

I also encountered this. Using any limits (like ylim() or scale_y_continuous()) will create this unwanted double axis. Can't imagine this being an wanted feature.

bpovahppeng commented 1 year ago

The extra text/ticks can be removed by manually setting those elements to be blank in a theme: theme(axis.text.y.right = element_blank(), axis.ticks.y.right = element_blank())

jolehtonen commented 1 year ago

Removing scale_y_continuous didn't help.

But thank you bpovahppeng! With your help, I managed to remove now the dual y-axis! In addition to text and ticks also the line needed to be removed. So whoever struggles with this later – this should work:

theme(axis.text.y.right = element_blank(), axis.ticks.y.right = element_blank(), axis.line.y.right = element_blank())