Reputation: 71
I have created the following ggplot using the code below. I need to remove the red vertical line on the right. Any help would be appreciated.
ggplot(model.1, aes(x = time, y = activity)) +
geom_line(aes(group = id), alpha = .3) +
geom_line(data = data, alpha = .9, size = 1, colour="red4") +
theme(panel.background = element_blank(),axis.line=element_line(colour="black"))+
scale_x_continuous(expand=c(0,0)) +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())+
labs(
x = "Time",
y = "Activity",
color = NULL
)
Upvotes: 1
Views: 673
Reputation: 11
You could try moving the group into the ggplot
layer:
ggplot(model.1,aes(x = time, y = activity, group=id))
And remove it from the geom_line
layer. I had a similar problem, and this got rid of the vertical line.
Upvotes: 1
Reputation: 11
It looks like the red vertical line is part of your data, I could be wrong though. If it is you can filter it:
filtered_data <- data %>% filter(time < 1)
And then use that within the geom_line function.
Upvotes: 0