I've produced a graph using ggplot and some data that represents the occurrence of specific management actions over the past decade. The graph looks great except for some vertical white spaces that appear within the plotted lines. Is there a way to remove these lines? I'm guessing they are caused by the grouping of my data (group=1). Any help would be appreciated. My code is below.
Also, I've used this stackoverflow question as guidance.
library(scales)
# Build data frame.
a7.data <- data.frame(date = seq(as.Date("2002/01/01"), as.Date("2013/05/01"), by="day"))
a7.data$year <- as.numeric(format(as.Date(a7.data$date), format="%Y"))
a7.data$month <- as.numeric(format(as.Date(a7.data$date), format="%m"))
a7.data$day <- as.numeric(format(as.Date(a7.data$date), format="%d"))
a7.data$status <- "Yes"
a7.data$filler_value <- 0
# Edit data frame for dates in which the management action was "no".
a7.data$status[a7.data$date >= "2002/01/01" & a7.data$date < "2002/07/01"] <- "No"
a7.data$status[a7.data$date >= "2005/05/20" & a7.data$date < "2005/08/25"] <- "No"
a7.data$status[a7.data$date >= "2005/12/31" & a7.data$date < "2006/04/12"] <- "No"
a7.data$status[a7.data$date >= "2006/11/06" & a7.data$date < "2006/12/31"] <- "No"
a7.data$status[a7.data$date >= "2007/01/31" & a7.data$date < "2007/07/02"] <- "No"
a7.data$status[a7.data$date >= "2008/02/01" & a7.data$date < "2009/08/11"] <- "No"
a7.data$status[a7.data$date >= "2010/02/28" & a7.data$date < "2010/03/15"] <- "No"
a7.data$status[a7.data$date >= "2010/05/09" & a7.data$date < "2010/07/07"] <- "No"
# Create a new column that creates a dummy year with which to plot the data in ggplot using faceting.
a7.data <- transform(a7.data, doy = as.Date(paste(1970, month, day, sep="/")))
# Custom colors.
ccolors <- c("#086CA2", "#FF8B00")
# ggplot code.
bb <- ggplot(a7.data, aes(doy, filler_value)) +
geom_line(aes(color=status, group=1), size=15, alpha=0.9) +
scale_x_date(label=date_format("%b"), breaks = "month") +
xlab("") + ylab("") + facet_grid(year~., scales="free") +
theme_bw() + theme(axis.text.y=element_blank()) +
theme(axis.ticks.y=element_blank()) +
scale_color_manual(values=ccolors, name="Article VII Restrictions?")
# Display plot.
bb