0

我正在生成一个 ecdf 图并想为其添加一个图例,但出现以下错误:

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

可能是什么问题呢?

4

1 回答 1

5

?legend是一个单独的函数,它不是plot调用的一部分。正如@timriffe 所说,您需要执行以下操作:

PrecentageVector1 <- c(10,20,30)
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, panel.first = grid()) 
legend("bottomleft",c("A","B","C"))
于 2013-01-13T01:14:01.097 回答