这是使用修改后的图例标签的解决方案
我使用了一些示例数据,因为没有添加可重现示例的数据。
#library
library(pROC)
library(ggplot2)
library(tidyverse)
# example data
roc.list <- roc(outcome ~ s100b + ndka + wfns, data = aSAH)
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases
#> Setting levels: control = Good, case = Poor
#> Setting direction: controls < cases
# extract auc
roc.list %>%
map(~tibble(AUC = .x$auc)) %>%
bind_rows(.id = "name") -> data.auc
# generate labels labels
data.auc %>%
mutate(label_long=paste0(name," , AUC = ",paste(round(AUC,2))),
label_AUC=paste0("AUC = ",paste(round(AUC,2)))) -> data.labels
# plot on a single plot with AUC in labels
ggroc(roc.list) +
scale_color_discrete(labels=data.labels$label_long)

如果您有多个 ROC 曲线,最好绘制一个平面图
# plot a facet plot with AUC within plots
ggroc(roc.list) +
facet_wrap(~name) +
geom_text(data = data.labels,
aes(0.5, 1,
label = paste(label_AUC)),
hjust = 1)

由reprex 包于 2021-09-30 创建(v2.0.1)