Reputation: 11833
I'm ploting my ROC curves with plotROC. Below is the example code. I need to plot multiple roc curves with the same color. I found I need to use alpha
in aes
. Now I need to control the transparency of my curves. Using alpha
in geom_roc
is not working. Does anyone knows what I can do? Thanks a lot.
D.ex <- rbinom(50, 1, .5)
rocdata <- data.frame(D = c(D.ex, D.ex),
M = c(rnorm(50, mean = D.ex, sd = .4),
rnorm(50, mean = D.ex, sd = 1)),
Z = rep(c('A', 'B', 'C', 'D', 'E'), each=20) )
library(plotROC)
ggplot(rocdata, aes(m=M, d=D, alpha=Z)) +
geom_roc(cutoffs.at = NULL, n.cuts=0, color='blue')+
theme(legend.position="none")
Upvotes: 0
Views: 499
Reputation: 28369
For plotROC::geom_rec
you have to set alpha
with linealpha
argument (not within aes
). But for this to work you also need to specify line group. Usually in ggplot2
it's done with group = Z
, but in geom_rec
it doesn't work. Quick solution would be to set color by Z
(color = Z
) and with scale_color_manual
set same color.
library(plotROC)
ggplot(rocdata, aes(m = M, d = D, color = Z)) +
geom_roc(cutoffs.at = NULL, n.cuts = 0, linealpha = 0.5) +
scale_color_manual(values = rep("black", length(unique(rocdata$Z)))) +
theme(legend.position = "none")
Upvotes: 2