Thank you very much I'll try this
Meytar From: Brian Diggs [via R] [mailto:ml-node+3415433-1829104127-202...@n4.nabble.com] Sent: Tuesday, March 29, 2011 6:46 PM To: meytar Subject: Re: plotting several ROC curves on the same graph On 3/29/2011 2:48 AM, meytar wrote: > Hello > I am trying to make a graph of 10 different lines built each from 4 > different > segments and to add a darker line that will represent the average of all > graphs > - all in the same plot.Actually each line is a ROC plot > The code I'm using for plotting one line is as follows: > > logit.roc.plot<- function(r, title="ROC curve") { > old.par<- par(no.readonly = TRUE); on.exit(par(old.par)) > par(xaxs="i", yaxs="i") > plot(1 - r$spec, r$sens, xlim=c(0, 1), ylim=c(0,1), type="l", > xlab="(1 - specificity): false positive rate", > ylab="sensitivity: true positive rate", > col="grey82", lwd=2); > points(1 - r$spec, r$sens,pch=20, cex=1.5, col="grey82") > abline(0, 1, lty=2); > segments(1-r$spec, 1-r$spec, 1-r$spec, r$sens, lty=3) > #text(1 - max(r$spec,na.rm=T), > r$sens[which.max(r$spec)],r$pts[which.max(r$spec)],pos=2,cex=0.8) > text(0, 0.9, paste("Area under ROC:",round(logit.roc.area(r),4)), pos=4) > title(main = title) > } > r[5,]=c(0,0,1,10) > logit.roc.plot(r) > r=r[-5,] > text(1 - max(r$spec,na.rm=T), > r$sens[which.max(r$spec)],r$pts[which.max(r$spec)],pos=2,cex=0.8) > > while r is a MATRIX (4x4) with > colnames=c("pts",sens","spec",iterationnumber.") > and I have for each ROC curve a different matrix but all matrices have the > same > size. (They are organized as a list of 10 matrices by the size 4X4 each) > > Would appreciate your help in putting all ROC curves on the same plot. > Thank you The reason you are getting new plots each time is the plot() call in the function. If you pull the plot initialization out of the function (so that the limits and axis labels get set up only once), then that plot could be replaced with a points call. -- Brian S. Diggs, PhD Senior Research Associate, Department of Surgery Oregon Health & Science University ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _____ If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/plotting-several-ROC-curves-on-the-same-graph- tp3414263p3415433.html To unsubscribe from plotting several ROC curves on the same graph, click here <http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by _code&node=3414263&code=bWV5dGFyQHR4LnRlY2huaW9uLmFjLmlsfDM0MTQyNjN8NzgxMTk0 Mzk3> . -- View this message in context: http://r.789695.n4.nabble.com/plotting-several-ROC-curves-on-the-same-graph-tp3414263p3415569.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.