This is my data.
Mod <- as.factor(c(rep("GLM",5),rep("MLP",5),rep("RF",5),rep("SVML",5),rep("SVMR",5)))
Manifold <- as.factor(rep(c("LLE","Iso","PCA","MDS","kPCA"),5))
ROC <- runif(25,0,1)
Sens <- runif(25,0,1)
Spec <- runif(25,0,1)
df <- data.frame("Mod"= Mod, "Manifold"= Manifold, "ROC" = ROC, "Sens" = sens, "Spec" = spec)
And I am making this graph
resul3 <- ggplot(df, aes(x = Mod, y = ROC, fill= Manifold)) + 
geom_bar(stat = "identity", position = "dodge", color = "black") +
ylab("ROC & Specificity") +
xlab("Classifiers") +
theme_bw() +
ggtitle("Classifiers' ROC per Feature Extraction Plasma") + 
geom_point(aes(y=Spec), color = "black", position=position_dodge(.9)) + 
scale_fill_manual(name = "Feature \nExtraction", values = c("#FFEFCA", 
"#EDA16A" ,"#C83741", "#6C283D", "#62BF94"))
first graph
And what I want is another legend with tittle "Specificity" and a single black point. I dont want the point to be inside the Manifolds legend.
Something like this but without the points inside the manifold squares
Changing the geom_point line, adding a scale_color_manual and using the override as seen in @drmariod's answer will result in this plot:
ggplot(df, aes(x = Mod, y = ROC, fill= Manifold)) + 
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  ylab("ROC & Specificity") +
  xlab("Classifiers") +
  theme_bw() +
  ggtitle("Classifiers' ROC per Feature Extraction Plasma") + 
  geom_point(aes(y=Spec, color = "Specificity"), position=position_dodge(.9)) + 
  scale_fill_manual(name = "Feature \nExtraction", values = c("#FFEFCA", 
                                                              "#EDA16A" ,"#C83741", "#6C283D", "#62BF94")) + 
  scale_color_manual(name = NULL, values = c("Specificity" = "black")) +
  guides(fill = guide_legend(override.aes = list(shape = NA)))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With