In running my code - I have x data and y data with a column identifier that I call FILLCOL. In my dataframe I have only two datasets so the column FILLCOL only has two unique identifiers. Yet - when I generate the plot, an extra label shows up in the legend. Appreciate any insight.
So - I've been working on this all morning. I was able to resolve the issue by removing empty data cells. I guess the modification of this question is how to ignore those cells without modifying the dataframe? I'm essentially eliminating outliers for that treatment but I don't want to delete the raw data. Thanks.
p<-ggplot(SCAT_PLOT.summary, aes(x=(SCAT_PLOT.summary$X_VALUE), y=(SCAT_PLOT.summary$Y_VALUE),colour=as.factor(SCAT_PLOT.summary$FILLCOL), fill=as.factor(SCAT_PLOT.summary$FILLCOL))) +
geom_point(shape=21, size = 4, alpha = 0.5, show.legend = TRUE) +
scale_color_brewer(type='div', palette=2)+
geom_smooth(method="glm", se=TRUE, fill = "blue", alpha = .05,
formula=formula)+
stat_poly_eq(formula = formula, size = 4,hjust = -.05,vjust = .5,
eq.with.lhs = "italic(y)~`=`~",
eq.x.rhs = "~italic(x)", color = "blue",
aes(label = paste(..eq.label.., ..rr.label.., sep = "*plain(\",\")~")),
parse = TRUE) +
theme_classic()+
xlab(x_axis_label)+
ylab(y_axis_label)+
theme(axis.text.x = element_text(color = "black", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "black", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "black", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "black", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain"))+
theme(panel.grid.minor = element_line(size = 0.25, linetype = 3,colour = "green"),
panel.grid.major = element_line(size = 0.25, linetype = 3,colour = "green"))+
theme( axis.line = element_line(colour = "darkblue", size = 1, linetype = "solid"))+
scale_fill_discrete(name = legend_label, labels = legend_text, na.translate = FALSE)+
scale_color_discrete(name = legend_label, labels = legend_text,guide = FALSE, na.translate = FALSE)+