R语言 我如何添加颜色到个别几何点?

t30tvxxf  于 2023-01-03  发布在  其他
关注(0)|答案(1)|浏览(111)

当前代码:
ggplot(compare, aes(x=specificity, y=false_positives)) + 
  geom_jitter(height=.02, color=specificity) +
  scale_discrete_manual(values=c("#999999", "#E69F00", "#56B4E9", "violet"))

manual_scale中的错误(外观、值、中断等):缺少参数“aesthetics”,无默认值

2w2cym1i

2w2cym1i1#

像这样?

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

数据:

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

相关问题