【问题标题】:Adding mean value to y-axis in plot将平均值添加到绘图中的 y 轴
【发布时间】:2016-06-12 10:53:43
【问题描述】:

我希望样本的平均值显示在我的 y 轴上。我试着像他们在 this post 中解释的那样做,但它似乎不起作用。如果你看image,红线代表平均值。我只需要在 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")

谢谢!

【问题讨论】:

    标签: r plot graph statistics mean


    【解决方案1】:
    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 可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-05
      • 2015-01-13
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      • 2022-12-19
      • 1970-01-01
      相关资源
      最近更新 更多