简体   繁体   English

在R中的同一图形中绘制多条曲线

[英]Plot multiple curves in the same graph in R

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()

here is the code for plotting single curve by taking data from single file. 这是通过从单个文件中获取数据来绘制单个曲线的代码。 i want to plot 3 curves in same plot by taking data from three different files ie file 1, file 2, file 3 please help me to do so 我想通过从三个不同的文件(即文件1,文件2,文件3)中获取数据来绘制同一曲线中的3条曲线,请帮助我这样做

you can add abline or curve directly. 您可以直接添加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')

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM