R - 使用多行绘制data.frame的图形

时间:2016-08-17 18:44:34

标签: r ggplot2

问题: 我有一个我构建的数据框,所以我可以创建一个看起来像这样的图形。 enter image description here

基本上我想要一个边界,然后在中间有一些线。

我无法理解如何做到这一点。我已经完成了一些教程,但可以使用一些特定的帮助。

数据 enter image description here

我已经建立了最基本的图表,但我没有看到前进的道路。

p <- ggplot(geomean.build.time.by.user)
p + geom_line(aes(x = week, y = user_geomean_build_time), stat = "smooth", method = "loess")

enter image description here

1 个答案:

答案 0 :(得分:0)

所以我把一个非常基本的图表放在一起。没有什么花哨。我只是想确定这些数据是否有价值。

p <- ggplot(geomean.build.time.by.user)
p + geom_line(aes(x = week, y = user_geomean_build_time), stat = "smooth", method = "loess", colour = "#00DCFF", size = 2) +
geom_line(aes(x = week, y = proj_geomean_build_time), colour = "#E85831", linetype = "dashed", size = 1) +
geom_line(aes(x = week, y = user_geomean_bt_plus_sd), colour = "#0ED26E", size = 2) +
geom_line(aes(x = week, y = user_geomean_bt_minus_sd), colour = "#0ED26E", size = 2) +
geom_line(aes(x = week, y = proj_geomean_bt_plus_sd), colour = "#00695D", size = 2) +
geom_line(aes(x = week, y = proj_geomean_bt_minus_sd), colour = "#00695D", size = 2)

修改

我接受了建议并改为丝带。总的来说它看起来更好,但它并没有给我我希望的观点。

p <- ggplot(geomean.build.time.by.user)
p + geom_line(aes(x = week, y = user_geomean_build_time)) +
geom_ribbon(aes(ymin = proj_geomean_bt_minus_sd, ymax =proj_geomean_bt_plus_sd, x = week, fill = "avg org build time +/- sd")) +
geom_ribbon(aes(ymin = user_geomean_bt_minus_sd, ymax = user_geomean_bt_plus_sd, x = week, fill = "avg dev build time +/- sd")) +
geom_line(aes(x = week, y = user_geomean_build_time), stat = "smooth", method = "loess", colour = "#F2F2F2", size = 2) +
geom_line(aes(x = week, y = proj_geomean_build_time), colour = "#F20404", linetype = "dashed", size = 1)