2016-05-25 79 views
2

我嘗試使用R繪製線條圖形。線條已被繪製,但abline線條不顯示。R:abline不會將線條添加到我的圖形中

M <- c(1.0,1.5,2.0,2.5,3) 
y <- c(0.0466,0.0522,0.0608,0.0629,0.0660) 
plot(M, y, type="l", col="red", xlab="sdr", 
    ylab="simulated type I error rate") 
abline(h=c(0.025,0.075),col=4,lty=2) 

這是我對圖的簡單編碼。任何方式使這條線彈出?

回答

3

試試這個:使用ylim

M <- c(1.0,1.5,2.0,2.5,3) 
y <- c(0.0466,0.0522,0.0608,0.0629,0.0660) 
plot(M, y, type="l",col="red",xlab="sdr", ylim = c(0.025, 0.075), 
    ylab="simulated type I error rate") 
abline(h=c(0.025,0.075),col=4,lty=2) 

我會參考你的另一篇文章閱讀我的答案:curve() does not add curve to my plot when 「add = TRUE」更多關於設置ylim當在圖上繪製幾個對象時。

+0

注意。非常感謝。有效。 ^^ – quess