Home > Blockchain >  How do I add color to individual geom points?
How do I add color to individual geom points?

Time:01-02

enter image description here

Current Code:
ggplot(compare, aes(x=specificity, y=false_positives))   
  geom_jitter(height=.02, color=specificity)  
  scale_discrete_manual(values=c("#999999", "#E69F00", "#56B4E9", "violet"))

Error in manual_scale(aesthetics, values, breaks, ...) : argument "aesthetics" is missing, with no default

CodePudding user response:

Something like this?

library(tidyverse)

ggplot(df, aes(x=specificity, y=false_positives, color= factor(specificity)))  
  geom_point(position = position_jitter())  
  scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9", "#8800FF"))  
  theme_bw()

enter image description here

data:

df <- structure(list(specificity = c(0.9, 0.87, 0.89, 0.91), false_positives = c(0.4, 
0.3, 0.4, 0.4)), row.names = c("Logistic", "Probit", "KNN", "Naive"
), class = "data.frame")
  • Related