Search code examples
rrocproc-r-package

Is it possible to change axis names in ggroc?


I am plotting multiple ROC-curves with ggroc, and would like the axis names to be "True positive rate" and "False positive rate", rather than sens and spec. Is it possible to do this with ggroc?

I have already tried the following which didn't work:

library(pROC)
ROC_curves <- ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), aes(TPR, FPR), legacy.axes=TRUE)   

I have also tried this: ROC_curves <- ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), legacy.axes=TRUE) + scale_x(name="FPR") + scale_y(name="TPR)


Solution

  • ggroc returns a standard ggplot object, so you can change the axis labels and everything exactly as you would for a standard ggplot:

    ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), legacy.axes=TRUE)
    ROC_curves + xlab("FPR") + ylab("TPR")
    

    Note that you are using legacy.axes=TRUE so that you can re-label the axis this way. Make sure to keep this argument, otherwise the labeling would be invalid.

    Also you can drop the aes(TPR, FPR) which is silently ignored.