title: How to add a legend to an ecdf plot?
body: <p>I am generating an ecdf plot and would like to add a legend to it, but getting the following error:</p>
  
  <pre><code>plot(xlim=c(0,100), ylim=c(0,1), main=NULL, xaxs="i", yaxs="i", 
       ecdf(PrecentageVector1),  col="red", do.p = FALSE, pch=19, 
       lwd=3,  legend("bottomleft",c("A","B","C")), panel.first = grid()) 
  
  Error in strwidth(legend, units = "user", cex = cex, font = text.font) :  
  invalid graphics state
  </code></pre>
  
  <p>What could be the problem?</p>