Created
February 25, 2016 21:45
-
-
Save sachsmc/5f7d110782e57d711882 to your computer and use it in GitHub Desktop.
Workaround to plot labels at precise points using plotROC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotROC) | |
D <- rbinom(100, 1, .4) | |
fkd <- data.frame(D = D, Y = rnorm(100, mean = D, sd = .5)) | |
p1 <- ggplot(fkd, aes(d = D, m = Y)) + geom_roc(n.cuts = 0) | |
dat <- ggplot_build(p1)$data[[1]] | |
mycut.i <- c(10, 50, 90) # find the indices of the labels you want to plot in dat above | |
p1 + geom_point(data = dat[mycut.i, ], | |
aes(d = NULL, m = NULL, x = x, y = y)) + | |
geom_text(data = dat[mycut.i, ], | |
aes(d = NULL, m = NULL, x = x - .03, y = y + .03, label = round(cutoffs, 1))) | |
p1 + geom_point(data = dat[mycut.i, ], | |
aes(d = NULL, m = NULL, x = x, y = y)) + | |
geom_label(data = dat[mycut.i, ], | |
aes(d = NULL, m = NULL, x = x - .03, y = y + .03, label = round(cutoffs, 1))) |
Author
sachsmc
commented
Feb 25, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment