I am plotting an interaction with ggplot using a script from last year. Last year this worked fine, but now that I installed a new version of ggplot2, it seems to have issues. The first issues was that the classic theme was not able to plot the X and Y-axis. I managed to solved this by adding it to the theme formatting. But now, stat_smooth produces three confidence bands when I have a two-level factor. Not sure why this is happening. This is the code:
gp <- ggplot(data=myData, aes(x=Sbfld,y=mem,colour=factor(status))) + geom_point(shape=17, size=8, na.rm=TRUE)
gp <- gp +
stat_smooth(method="lm", size=2, na.rm=TRUE) +
scale_y_continuous(breaks=seq(-4, max(mem)*1.1, 0.5)) +
theme_classic(base_size=35) +
theme(legend.position="bottom",
legend.title=element_blank(),
legend.text=element_text(size=30, face="bold"),
legend.key.size=unit(2, "cm"),
legend.background = element_rect(colour="black"))+
theme(axis.line.x=element_line(colour="black", size=0.5, linetype="solid"),
axis.line.y=element_line(colour="black", size=0.5, linetype="solid"),
axis.title.y=element_text(vjust=1.6, size = 40, face="bold"),
axis.title.x = element_text(vjust=-0.2, size = 40, face="bold"),
axis.text.x = element_text(size=25,colour="#333333"),
axis.text.y = element_text(size=25,colour="#333333"),
panel.grid.minor=element_blank())
Status has two levels: positive and negative and there are about 7 missing values. X and Y are continuous and there are no missing values there.
This is the output:ggplotoutput
Is this a bug in ggplot? Does anybody know how to solve this?
Thanks!