I'm making a Shiny app, and I'm using geom_line(aes(x= x, y =y, group = g, colour = g), size=2, na.rm=T)
and then geom_point(aes(x= x, y = x, group = g, colour = g), size=5, na.rm=T, shape=16)
and I have the line of one group (here in green) behind the points but above the line of an other group (here in pink).
Code:
library(ggplot2)
ggplot(data=df2, aes(x=DateRelCases, y = CasesCumMod)) +
geom_line(aes(x= DateRelCases, y =CasesCumMod, group = Country, colour = Country), size=2, na.rm=T) +
geom_point(aes(x= DateRelCases, y =CasesCumMod, group = Country, colour = Country),size=5, na.rm=T, shape=16)
Data:
df2 <- data.frame(Country = structure(c(rep(2L, 30), rep(3L, 30), rep(1L, 30)), .Label = c("ES", "FR", "IT"), class = "factor"),
DateRelCases = structure(rep(30:1,3)),
CasesCumMod = c(40174, 37575, 32964, 29155, 25233, 22302,
19856, 16018, 14459, 12612, 10995, 9134, 7730, 6633, 5423,
4499, 3661, 2876, 2281, 1784, 1412, 1126, 716, 613, 423,
285, 212, 178, 130, 100, 97689, 92472, 86498, 80539, 74386,
69176, 63927, 59138, 53578, 47021, 41035, 35713, 31506, 27980,
23980, 17750, 17660, 15113, 12462, 10149, 9172, 7375, 5883,
4636, 3858, 3089, 2502, 1835, 1689, 1128, 78797, 72248, 64059,
56188, 47610, 39673, 33089, 28572, 24926, 19980, 17147, 13716,
11178, 9191, 7753, 5753, 4231, 3004, 2140, 1639, 1204, 589,
430, 374, 261, 200, 151, 114, 83, 66))