You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整R语言ROC图中AUC值的显示位置?

Adjusting AUC Display Position in pROC Plot (R)

Hey there! I get it—tweaking the AUC label position on your ROC plot can be tricky even when you’ve set print.auc=TRUE and location. Let’s fix this with a few targeted adjustments using the pROC package’s built-in parameters.

Key Context: pROC’s Coordinate System

First, remember that the location parameter uses relative coordinates (0 to 1):

  • (0, 0) = Bottom-left corner of the plot
  • (1, 1) = Top-right corner

Your original location=c(0.2,1) places the AUC label near the top-left edge, which might overlap with grid lines or threshold text (from print.thres=TRUE). Let’s adjust this.

Solution 1: Fine-Tune the location Parameter

Simply adjust the x/y values to move the label to a less crowded spot. For example, to place it in the bottom-right corner:

plot(modelroc, 
     print.auc=TRUE,
     location=c(0.8, 0.2),  # Bottom-right area
     auc.polygon=TRUE, 
     grid=c(0.1, 0.2), 
     grid.col=c("green", "red"), 
     max.auc.polygon=TRUE, 
     auc.polygon.col="skyblue", 
     print.thres=TRUE)

Or if you want it top-right instead:

location=c(0.8, 0.9)

Solution 2: Use print.auc.x and print.auc.y for Precise Control

For even more granularity, replace location with separate x/y parameters for the AUC label:

plot(modelroc, 
     print.auc=TRUE,
     print.auc.x=0.7,  # Exact horizontal position
     print.auc.y=0.3,  # Exact vertical position
     print.auc.cex=0.8,  # Shrink font size if needed
     auc.polygon=TRUE, 
     grid=c(0.1, 0.2), 
     grid.col=c("green", "red"), 
     max.auc.polygon=TRUE, 
     auc.polygon.col="skyblue", 
     print.thres=TRUE)

The print.auc.cex parameter helps if the label is too large and overlapping other elements.

Solution 3: Avoid Conflicts with Threshold Text

If your AUC label is clashing with the threshold values (from print.thres=TRUE), you can adjust the threshold text position too:

plot(modelroc, 
     print.auc=TRUE,
     location=c(0.2, 0.8),  # Move AUC down from top
     print.thres.x=0.5,  # Adjust threshold text x-position
     print.thres.y=0.5,  # Adjust threshold text y-position
     auc.polygon=TRUE, 
     grid=c(0.1, 0.2), 
     grid.col=c("green", "red"), 
     max.auc.polygon=TRUE, 
     auc.polygon.col="skyblue", 
     print.thres=TRUE)

Alternatively, temporarily set print.thres=FALSE to test the AUC position without distractions, then re-enable it once you’re happy with the AUC placement.

内容的提问来源于stack exchange,提问作者Kyan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:59:25