ggprroc | R Documentation |
Plots the PR or ROC curves of a PRROC object using ggplot2. To obtain such curves, pr.curve
or roc.curve
must be called with
argument curve=TRUE
.
ggprroc(x, auc.main=TRUE, auc.type=c("integral","davis.goadrich"),
xlab=NULL,ylab=NULL,
main=NULL,
max.plot = FALSE, min.plot = FALSE, rand.plot = FALSE,
fill.area = (max.plot & min.plot))
x |
a PRROC object obtained from |
auc.main |
|
auc.type |
the area under the curve shown in the title (see also |
xlab |
the label of the x-axis. If |
ylab |
the label of the y-axis. If |
main |
the title of the plot. If |
max.plot |
if |
min.plot |
if |
rand.plot |
if |
fill.area |
fill the area between maximum and minimum curve (given both have been computed for |
This function plots PRROC objects as a curve using ggplot2, specifically geom_line
. If minimum, maximum or random curves have been computed, these can be added to the plot.
The function returns a ggplot2 object that may be further modified using themes, scales on the colours, etc.
Jan Grau and Jens Keilwagen
pr.curve
roc.curve
# create artificial scores as random numbers
x <- rnorm( 1000 );
y <- rnorm( 1000, -1 );
# compute PR curve
pr <- pr.curve( x, y, curve = TRUE );
# standard plot of PR curve
ggprroc( pr );
# compute ROC curve
roc <- roc.curve( x, y, curve = TRUE );
# standard plot of ROC curve
ggprroc( roc );
# include maximum, minimum and random curves
pr <- pr.curve( x, y, curve = TRUE, max.compute = TRUE,
min.compute = TRUE, rand.compute = TRUE );
ggprroc( pr, max.plot = TRUE, min.plot = TRUE, rand.plot = TRUE )
# modify theme and colour scale
pl <- ggprroc( pr, max.plot = TRUE, min.plot = TRUE, rand.plot = TRUE )
if(require(ggplot2)){
pl + scale_color_viridis_c(option="D",name="Some score") +
xlab("Sensitivity")+
theme_gray()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.