library(ggplot2) ybar <- mean(lh) lh2 <- c(ybar,lh,ybar) df4plot <-data.frame(time=1:length(lh2), lh=lh2) df4plot$lower <- ifelse(lh2<=ybar,lh2,ybar) ggplot(df4plot,aes(x=time,y=lh))+ geom_line()+ geom_polygon(aes(x=time, ymin=lower,ymax=lh),alpha=0.3)+ geom_hline(yintercept=ybar)
↧
[ggplot2]折れ線グラフを基準値の上下で塗りつぶす
↧