読者です 読者をやめる 読者になる 読者になる

plot関数で参照線を引く方法の補足? (panel.first)

barplotでやると盛大にはみ出ます・・・

Ety <- function(y) {
  n <- 20
  return( (y+1)/(n+2) )
}
par(mar=c(3.2, 3.2, 1.5, 0.5), mgp=c(2.0, 0.7, 0))
par(bty="l")
names <- replace(seq(0, 20), which(seq(0, 20) %% 5 != 0), NA)
barplot(
  Ety(seq(0,20)),
  col = "#E64B6B", border = NA,
  ylim = c(0, 1), space = 0.2, beside = T, names.arg = names,
  xlab = expression(y),
  ylab = expression(paste("E(", theta ,"|", y, ")")),
  main = expression(paste(n, " = ", 20)),
  panel.first = abline(h = seq(0, 1, 0.2), lty = 2, col = "#E9DECA")
)
abline(h = 0, lty=1)
abline(h = 0.5, lty=2)
text(1, 0.55, expression(paste("E(", theta, ") = ", over(1,2))), cex = .8)