Reputation: 1931
I'm playing with the ROC function in the Epi package, whose documentation specifies that you can pass graphical parameters to the plot function. By default, ROC produces a grayscale graph. I'm trying to color only the ROC curve itself (the jagged line) red.
Here's what I tried:
x = rnorm(100)
y = c(rep(0,50), rep(1,50))
library(Epi)
par(col="red"); ROC(form = y~x, plot="ROC")
This creates a strange graph with inconsistent coloring. The par documentation does describe some specific methods like col.lab and col.axis to color specific graphical elements, but doesn't include a parameter for the main line color.
I have to think this basic question must have been addressed elsewhere, but so far haven't had luck searching the R documentation and Google.
Upvotes: 1
Views: 1579
Reputation: 173547
For your specific case, if you want to modify the function ROC
to suit your needs, you can do the following. Type ROC
at the console to see the code for ROC
. Copy and paste it into a file and assign it a new name, like ROC2
. Look for the following code:
if (any(!is.na(match("ROC", toupper(plot))))) {
plot(1 - res[, 2], res[, 1], xlim = 0:1, xlab = "1-Specificity",
ylim = 0:1, ylab = "Sensitivity", type = "n", ...)
if (is.numeric(grid))
abline(h = grid/100, v = grid/100, col = gray(0.9))
abline(0, 1, col = gray(0.4))
box()
lines(1 - res[, 2], res[, 1], lwd = lwd)
You'll want to pass col = "red"
, or some such, in the lines
call. For instance you could add a mycol
argument to the function itself and then change that one line to:
lines(1 - res[, 2], res[, 1], lwd = lwd, col = mycol)
Also, as I noted below, you will also have to change all instances of ROC.tic
to Epi:::ROC.tic
.
Upvotes: 1