在下面的图表中,波形上方有一条彩色线,表示每个时间点的统计意义(灰色:不显着,蓝色阴影:显着,蓝色越深表示t得分越多)。
数据帧data
:
data <- structure(list(x = -10:10, y = c(1.17212311444692, 0.0796231128715192,
0.0884179665923377, 0.528897391178863, -0.943528827648172, 0.0677093946037336,
-0.553815297396959, -2.09355889431236, -1.4073660716519, 2.15345031622522,
1.32470201744841, 1.7682989226011, -0.36884335521017, -1.02874953756008,
0.706049415549804, -0.622101718842982, -0.670885289277569, 0.178799361542821,
-0.0387849590281491, -2.11303096472901, -1.76748424511596)), class = "data.frame", row.names = c(NA,
-21L))
情节:
library(ggplot2)
ggplot(data=data, aes(x=x, y=y)) +
geom_hline(aes(yintercept=0)) +
geom_vline(aes(xintercept=0)) +
geom_line()+
geom_segment(aes(x=-10, xend=3, y=4.5, yend=4.5), color="grey", size=2) +
geom_segment(aes(x=3, xend=6, y=4.5, yend=4.5), color="dodgerblue2", size=2) +
geom_segment(aes(x=6, xend=7.5, y=4.5, yend=4.5), color="blue2", size=2) +
geom_segment(aes(x=7.5, xend=8, y=4.5, yend=4.5), color="blue4", size=2) +
geom_segment(aes(x=8, xend=9, y=4.5, yend=4.5), color="blue2", size=2) +
geom_segment(aes(x=9, xend=10, y=4.5, yend=4.5), color="grey", size=2)
我需要做的是也要有类似热图的颜色图例。有人对如何做有任何想法吗?我找到的所有解决方案均参考geom_tile
命令,但我不知道如何使其适合我的绘图需求。