【问题标题】:Plot multiple curves in the same graph in R在 R 中的同一图中绘制多条曲线
【发布时间】:2017-11-30 08:57:05
【问题描述】:
library(ROCR);    
lig <- unique(read.table("ligands.txt")[,1]);
dec <- unique(read.table("decoys.txt")[,1]);
uniqRes <- read.table("file1.txt",header=T);
colnames(uniqRes)[1]="LigandName";
uniqRes$IsActive <- as.numeric(uniqRes$LigandName %in% lig)
predTOTALuq <- prediction(uniqRes$TOTAL*-1, uniqRes$IsActive)
perfTOTALuq <- performance(predTOTALuq, 'tpr','fpr')
jpeg("hivpr_Rinter_ROC.jpg") 
plot(perfTOTALuq,main="hivpr - ROC Curves",col="blue")
abline(0,1,col="grey")
dev.off()

这里是通过从单个文件中获取数据来绘制单个曲线的代码。 我想通过从三个不同的文件(即文件 1、文件 2、文件 3)中获取数据来在同一个图中绘制 3 条曲线 请帮我这样做

【问题讨论】:

    标签: r


    【解决方案1】:

    您可以直接添加ablinecurve

    df1 <- data.frame(x = 1:10, y = 1:10)
    df2 <- data.frame(x = 1:13, y = 2:14)
    df3 <- data.frame(x = 6:10, y = 2:6)
    lx <- range(c(df1$x, df2$x, df3$x))
    ly <- range(c(df1$y, df2$y, df3$y))
    
    plot(df1, main = "hivpr - ROC Curves", xlim = lx, ylim = ly, col = "blue")
    abline(0, 1, col = "blue") 
    points(df2, col = 'red3')
    points(df3, col = 'yellow')
    

    【讨论】:

    • 前两个文件是配体.txt 和 decoys.txt 保持不变实际上我想为三个文件更改此命令,即 uniqRes
    • 只是 ROC 曲线的线
    • 上面的代码能解决你的问题吗?如果不能,你dput一些数据来自你的file1file2file3,然后我可以重现你的问题。
    • _ Title1总锌08940419 -11.782锌18200582 -11.738 ZINC20907200 -11.666锌0.11.504 ChemBl606000.mol -11.503 ZINCO5341415 -11.046 ChemBl1651485.Mol -11.012 ZINC20907206 -10.838 SPAN>
    • 其他两个文件看起来和这个一样
    猜你喜欢
    • 1970-01-01
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    • 2011-05-02
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    相关资源
    最近更新 更多