Scale_x_break with ggplot returns vertical line at break point

I am working on time series data that I plotted with ggplot. Now I want to break the x-axis to not show specific dates. I did that successfully with scale_x_break but at the point of break there is a vertical line I do not know how to remove. Also, I want to remove the x-axis label which got inserted when running the scale_x_break line.

I show the ggplot code below

#>timeseries rainfall plot
R_code<-
ggplot(DK_cumlrain, aes(x = Index, y = Rain_mm_TOT, colour = site)) +
  geom_line(size = 0.71) +
  geom_vline(aes(xintercept = as.Date(as.POSIXct("2019-12-31"))), linetype="solid", col="black", size = 0.8) +
  geom_text(data = dat_text,mapping = aes(x=x, y = y, label = label),size=4,angle=90,vjust=-0.6,col="blue")+
  scale_colour_manual(values=c("navy","skyblue3"), labels=c("Fynbos", "Renosterveld"), name="Site") +
  scale_x_date(date_breaks = "1 month", date_labels = "%b") + 
  scale_x_break(c(as.Date("2020-04-25"), as.Date("2020-09-01")), scales ="free") +
  annotate("text", x = as.Date(as.POSIXct("2019-11-01")), y = 10, label = "2019")+
  annotate("text", x = as.Date(as.POSIXct("2020-01-15")), y = 10, label = "2020")+
  ylab("Daily rainfall (mm)") +
  xlab(" ") +

  theme_bw()

It will be difficult for forum users to help you without example representative data that your code could ingest.
p.s. ggplot2 does not have scale_x_break, I believe this means you have a package dependency on ggbreak.

library(tidyverse)
library(ggbreak)

ggplot(data=data.frame(x=1:20,
                       y=(1:20 -8) ^3)) +
    aes(x=x,y=y) + geom_line() + 
    scale_x_break(breaks=c(10,15),scales = "free")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.