【发布时间】:2015-07-11 07:51:58
【问题描述】:
我已经模拟了这个data.frame:
library(plyr); library(ggplot2)
count <- rev(seq(0, 500, 20))
tide <- seq(0, 5, length.out = length(count))
df <- data.frame(count, tide)
count_sim <- unlist(llply(count, function(x) rnorm(20, x, 50)))
count_sim_df <- data.frame(tide=rep(tide,each=20), count_sim)
而且可以这样绘制:
ggplot(df, aes(tide, count)) + geom_jitter(data = count_sim_df, aes(tide, count_sim), position = position_jitter(width = 0.09)) + geom_line(color = "red")
我现在想将count_sim_df 分成两组:high 和low。当我绘制分割count_sim_df 时,它应该看起来像这样(绿色和蓝色的所有内容都经过了photoshop)。我发现棘手的一点是在high 和low 之间在tide 的中间值附近重叠。
这就是我想将count_sim_df 分成高低的方式:
- 将
count_sim_df的一半分配给high,将count_sim_df的一半分配给low - 重新分配
count的值,以在tide的中间值附近创建high和low之间的重叠
【问题讨论】:
标签: r ggplot2 dataframe visualization