I have created the code for displaying a confidence interval for the ROC curve for both Logistic and Random Forest. But I would like to have 1- specificity in the x-axis instead of specificity. The code is
roc.list <- roc(test_df$extry ~ Logistic_Regression+Random_Forest)
ci.list <- lapply(roc.list, ci.se, specificities = seq(0, 1, l = 10))
dat.ci.list <- lapply(ci.list, function(ciobj)
data.frame(x = as.numeric(rownames(ciobj)),
lower = ciobj[, 1],
upper = ciobj[, 3]))
p <- ggroc(roc.list,legacy.axes=TRUE) + theme_minimal() + geom_abline(slope=1, intercept = 1, linetype = "dashed", alpha=0.7, color = "grey") + coord_equal()
for(i in 1:3) {
p <- p + geom_ribbon(
data = dat.ci.list[[i]],
aes(x = x, ymin = lower, ymax = upper),
fill = i + 1,
alpha = 0.2,
inherit.aes = F)
}
p

I assume you are using the
ggrocfunction from thepROCpackage.When you run
ggrocwithlegacy.axes=TRUE, theggplotfunction is called with the following aesthetics:As identified by @Allan Cameron in the comments, you need to specify compatible aesthetics that specify 1-specificity in x: