j'utilise ggplot pour faire une représentation graphique de l'effets de plusieurs traitements au cours du temps.
Dans mon exemple j'obtiens 8 courbes : 4 sont obtenues en présence d'antibiotique et 4 sans.
Je souhaiterais que les 4 courbes avec antibiotique apparaissent avec un dégradé de couleur bleu par exemple et que les 4 courbes sans antibiotique apparaissent dans un dégradé d'une autre couleur.
Mais je ne sais pas comment faire, ni si cela est possible.
Merci de votre aide.
Voici mon script :
Code : Tout sélectionner
library(ggplot2)
library(RColorBrewer)
p <- ggplot(plate, aes(x=day, y=nCells, group=interaction(Trait1, Trait2a), colour=interaction(Trait1, Trait2a))) +
geom_line() +
geom_point()
print(p)
et mon dataframe :
Code : Tout sélectionner
plate <- structure(list(Cond = structure(1:28, .Label = c("j1_05_woATB",
"j1_10_woATB", "j1_20_woATB", "j1_50_woATB", "j2_05_ATB", "j2_05_woATB",
"j2_10_ATB", "j2_10_woATB", "j2_20_ATB", "j2_20_woATB", "j2_50_ATB",
"j2_50_woATB", "j3_05_ATB", "j3_05_woATB", "j3_10_ATB", "j3_10_woATB",
"j3_20_ATB", "j3_20_woATB", "j3_50_ATB", "j3_50_woATB", "j4_05_ATB",
"j4_05_woATB", "j4_10_ATB", "j4_10_woATB", "j4_20_ATB", "j4_20_woATB",
"j4_50_ATB", "j4_50_woATB"), class = "factor"), nCells = c(47.1852,
53.5185, 53.7778, 50.5556, 95.1481, 120.63, 96.9259, 125.519,
86.8148, 105.296, 84.5185, 89.8889, 182.259, 281.37, 203.111,
245.778, 226.333, 302.259, 222.222, 281.741, 381.741, 587.815,
387.333, 619.593, 486.852, 733.704, 480.259, 624.963), DeadCells = c(2.19499,
1.12132, 2.61569, 1.97872, 1.8776, 1.11307, 3.62967, 1.19153,
5.71182, 2.22468, 6.04897, 1.54371, 30.909, 1.31003, 10.0827,
1.81695, 9.6289, 2.2471, 15.975, 6.1745, 4.5747, 1.05255, 7.50961,
2.63833, 4.14927, 4.94735, 2.96878, 15.829), day = c(1, 1, 1,
1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
4, 4, 4, 4), Trait = structure(c(2L, 4L, 6L, 8L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L), .Label = c("05_ATB", "05_woATB", "10_ATB",
"10_woATB", "20_ATB", "20_woATB", "50_ATB", "50_woATB"), class = "factor"),
Trait1 = structure(c(1L, 2L, 3L, 4L, 1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L,
3L, 3L, 4L, 4L), .Label = c("5", "10", "20", "50"), class = "factor"),
Trait2a = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L), .Label = c("ATB", "woATB"), class = "factor"),
Trait2b = structure(c(2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L), .Label = c("ATB", "woATB"), class = "factor")), .Names = c("Cond",
"nCells", "DeadCells", "day", "Trait", "Trait1", "Trait2a", "Trait2b"
), row.names = c(NA, -28L), class = "data.frame")
Patricia