ggroc.roc {pROC} | R Documentation |
This function plots a ROC curve with ggplot2.
## S3 method for class 'roc' ggroc(data, ...) ## S3 method for class 'list' ggroc(data, aes = c("colour", "alpha", "linetype", "size"), ...)
data |
a roc object from the roc function, or a list of roc objects. |
aes |
the name of the aesthetics for |
... |
additional aesthetics for |
This function initializes a ggplot object from a ROC curve (or multiple if a list is passed). It returns the ggplot with a line layer on it. You can print it directly or add your own layers and theme elements.
This function is experimental and may change in the future. Please report bugs and feedback on the GitHub issue tracker.
# Create a basic roc object data(aSAH) rocobj <- roc(aSAH$outcome, aSAH$s100b) rocobj2 <- roc(aSAH$outcome, aSAH$wfns) library(ggplot2) g <- ggroc(rocobj) g # with additional aesthetics: ggroc(rocobj, alpha = 0.5, colour = "red", linetype = 2, size = 2) # You can then your own theme, etc. g + theme_minimal() + ggtitle("My ROC curve") # Multiple curves: g2 <- ggroc(list(s100b=rocobj, wfns=rocobj2)) g2 # with additional aesthetics: g2 <- ggroc(list(s100b=rocobj, wfns=rocobj2), linetype=2) ggroc(list(s100b=rocobj, wfns=rocobj2), aes="linetype", color="red")