Question
Remove gap in line plot in R
Please help me plot a single line that changes from solid (measured) to dashed (estimate) after year 2008 and has a legend respectively. My code:
date<-as.POSIXct(c("1981-01-01","2008-01-01", "2024-01-01", "2050-01-01"), format = "%Y-%m-%d", tz=Sys.timezone())
sed_pool_vol<-as.numeric(c(0, 938, 1493, 2397 ))
group<- c("measured", "measured", "estimate", "estimate")
sed_df<-data.frame(date, sed_pool_vol,group)
ggplot(sed_df, aes(x = date, y = sed_pool_vol,linetype = group)) +
geom_line()+
scale_linetype_manual("group",values=c("estimate"=2,"measured"=1))
2 29
2