2016-02-29 87 views
0

我想要在我的y軸上顯示樣本的平均值。我試過這樣做,就像他們在 this post中解釋過的那樣,但它似乎不起作用。如果你看看image,紅線代表平均值。我只需要在y軸上顯示的值。任何幫助表示讚賞。在plot中向y軸添加平均值

我的R代碼裏面:

xyear = seq(1920,1978,1) 
plot(xyear,difference, type = "bar", col = "blue", main = "Difference between precipitation in winter and summer", xlab = "Year", ylab = "Difference") 
abline(difference.mean, 0, col = "red") 

謝謝!

回答

0
xyear = seq(1920,1978,1) 
plot(xyear,difference, type = "bar", col = "blue", main = "Difference between precipitation in winter and summer", xlab = "Year", ylab = "Difference") 
abline(mean(difference), 0, col = "red") 
axis(side = 2, at=mean(difference), labels=T) 

axis命令在這種情況下應該有所幫助。欲瞭解更多信息,this page可能會有所幫助。

+0

謝謝Burak!有效。 –