Antonio
Antonio

Reputation: 407

How do I add color to individual geom points?

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

Upvotes: 1

Views: 644

Answers (1)

TarJae
TarJae

Reputation: 79266

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")

Upvotes: 4

Related Questions