在同一图中绘制x范围不同部分的标准误差均值

时间:2019-06-09 15:26:26

标签: r plot

我想给出绘图中x范围各个部分的y值的平均值和标准误差。即在灰色垂直线之间。用谷歌搜索,并在没有帮助的情况下检查了所有以前的答案。

数据框:

dput(data) structure(list(Year = c(1970, 1971, 1972, 1973, 1974, 1975, 1976, 
1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 
1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 
2010, 2011, 2012, 2013, 2014, 2015, 2016), Tot = c(52, 46, 19, 
52, 94, 102, 104, 143, 117, 146, 135, 132, 152, 134, 138, 141, 
134, 134, 134, 145, 152, 126, 139, 138, 97, 120, 97, 98, 76, 
84, 102, 98, 99, 96, 96, 98, 102, 102, 107, 109, 109, 107, 112, 
107, 93, 114, 108)), row.names = c(NA, -47L), class = c("tbl_df", 
"tbl", "data.frame"))

情节脚本:

plot(data$Year,data$Tot,type="b",xlab="" ,ylab="",
 ylim=c(0,200),lty="solid",lwd=2,col='black',cex.lab=1.5,las=1,cex=1.5)
abline(v=1994,col="grey",lty="dotted",lwd=3)
abline(v=2005,col="grey",lty="dotted",lwd=3)
abline(v=2010,col="grey",lty="dotted",lwd=3)

绘图输出加上手动绘制的均值和标准误差阴影: enter image description here

1 个答案:

答案 0 :(得分:1)

经过编辑以反映OP的修订后的帖子

open class UserParamsDto(

        var user: Long? = null,
        var height: Int? = null,
        var weight: Double? = null,
        var gender: String? = null,
        var birthDate: LocalDateTime? = null

) : AbstractDto()

open class AbstractDto(

        var id: Long? = null,
        var created: LocalDateTime? = null,
        var updated: LocalDateTime? = null
)