Angus Campbell
Angus Campbell

Reputation: 592

ROC plot in roc.plot is exending axis beyond the ylim and xlim

The following code produces the roc plot below. It seems to be ignoring the limits I've set on the axis. How can I get the plot to stop at 0 and 100?

roc(rdb$Engramcell,
    rdb$ActivityScore, 
    plot=TRUE, legacy.axes=TRUE, percent=TRUE, 
    plot.window(xlim=c(100, 0),
                ylim=c(0, 100)),
    xlab="False Positive Percentage", ylab="True Postive Percentage", 
    col="firebrick4", lwd=1, print.auc=TRUE)

enter image description here

Upvotes: 0

Views: 205

Answers (1)

Calimo
Calimo

Reputation: 7969

First, you didn't set the limits properly, you should pass xlim and ylim directly, not a call to plot.window.

roc(...,
    percent=TRUE, 
    xlim=c(100, 0),
    ylim=c(0, 100)),
    ...)

But this wouldn't change your plot. By default, R extends the data range by around 4%. These margins are controlled by the xaxs and yaxs graphical parameters. Setting them to "i" removes the margins:

library(pROC)
roc(aSAH$outcome, aSAH$ndka, plot=TRUE, xaxs="i", yaxs="i")

A plot with no margin

Upvotes: 0

Related Questions