I am trying to make a plot like this in an easy way with ggplot (or base R)
The idea is to consider the dark line as a single group with a gap between two subgroups (CAP and NC), and also to put a second x lab to tag times (as you can see, times 0,15 and 240 are common to both groups).
Thanks for your help,
EDIT: Here there is an example.
db0 <- structure(list(t = c(0, 5, 15, 30, 60, 0, 15, 60, 0, 5, 15,
30,60, 0, 15, 60), g = c("C", "C", "C", "C", "C", "N", "N", "N",
"C", "C", "C", "C", "C", "N", "N", "N"), v = c("T1", "T1", "T1",
"T1", "T1", "T1", "T1", "T1", "T2", "T2", "T2", "T2", "T2", "T2",
"T2", "T2"), y = c(10, 12, 15, 25, 33, 10, 13, 11, 11, 20, 28,
14, 10, 11, 11, 12), x = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L)), row.names = c(NA, -16L), class =
"data.frame")
db0$x <- rep(1:8, length.out=16)
library(ggplot2)
ggplot(db0, aes(x=as.factor(x), y=y, group=g, color=v)) +
geom_path() +
geom_point() +
scale_x_discrete(labels=c("1" = "0", "2" = "5", "3" = "15", "4" = "30",
"5" = "60", "6" = "0", "7" = "15", "8" = "60"))
The question here is how to do this plot in an easy way, without creating the x variable and the changing the x-lab names, but with ggplot2 commands. Also, Having problems with geom_path that links the end of one group with the beginning of the following.