2013-01-13 4 views
0

가 나는 ecdf 플롯을 생성하고 그것에 범례를 추가하고 싶지만, 다음과 같은 오류지고 :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 

어떤 문제가 될 수 있습니까?

+1

: @timriffe 말한다 , 당신은 뭔가를 할 필요가있다. 일반적으로'plot()' –

답변

5

?legend은 모두 고유 한 기능이며 plot 호출의 일부가 아닙니다. 내가 오류를 인식하지 않고 당신이 우리에게`PrecentageVector1` (원문)을 제공하지 않았기 때문에 그것을 재현 할 수없는

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")) 
+0

'panel.first = grid()'가 의심스러운 후에'legend()'를 호출 해보십시오. 그것이'plot.ecdf' (etc)에 의해 실제로 사용되는지 알고 있습니까? –

+0

@MatthewLundberg - 전 그렇게 생각하고 전에 보지 못했지만 작동합니다! 'plot (1 : 10, panel.first = grid())'또한'panel.last ='-'plot (1 : 10, panel.first = grid(), panel.last = abline (v = 4, col = "red"), pch = 19)'? plot.default'를보십시오 – thelatemail

+0

고마워요. 차이를보기 위해 인수를 추가하거나 추가하지 않고 앞뒤로 뒤집어 써야했습니다. 눈금 선은 나의 감시자에 아주 feint이다. 처음에는 아무 것도하지 않는 것 같아요. 그래서 그 논쟁이 어딘가에 '...'로 빠져 든 것 같았습니다. –

관련 문제