My data looks something like this:
# A tibble: 6 x 4
CFU strain diltn order
<dbl> <fctr> <dbl> <dbl>
1 0.0 M12-611025 (0) 5.89279 1
2 1.0 M12-611025 (0) 5.19382 1
3 0.0 M12-611025 (0) 4.49485 1
4 0.5 M12-611025 (0) 3.79588 1
5 1.0 M12-611025 (0) 3.09691 1
6 7.0 M12-611025 (0) 2.39794 1
I have 16 different "strains" and only want to plot a subset onto my graph as well as using geom_smooth to draw a line. I have achieves this as follows:
lines1 <- c("M12-611025 (0)" = "solid",
"M12-611025 (0) HI" = "dashed",
"M12-611025 (300)" = "solid",
"M12-611025 (300) HI" = "dashed",
"M12-611025 (700)" = "solid",
"M12-611025 (700) HI" = "dashed",
"M12-611025 (1100)" = "solid",
"M12-611025 (1100) HI" = "dashed")
ggplot(data = (subset(data,
strain %in% c("M12-611025 (0)", "M12-611025 (0) HI",
"M12-611025 (300)", "M12-611025 (300) HI",
"M12-611025 (700)", "M12-611025 (700) HI",
"M12-611025 (1100)", "M12-611025 (1100) HI"))),
(aes(x = diltn, y = CFU, colour = factor(strain),
fill = factor(strain), linetype = factor(strain)))) +
geom_smooth(se = F, span = 1) +
geom_point(shape = 21, colour = "black", size = 2, stroke = 1) +
scale_y_continuous(limits = c(-1, 120))+
scale_x_continuous(breaks = c(0, 1, 2, 3, 4),
labels = c(0, 10, 100, 1000, 10000),
limits = c(1, 4))+
annotation_logticks(base = 10, sides = "b", scaled = TRUE) +
theme(axis.line = element_line(colour = "black",
size = 1,
linetype = "solid")) +
ggtitle("RPM Test M12 - 611025") +
xlab(expression(paste("Dilution "))) +
ylab("CFU") +
scale_linetype_manual(values = lines1)
The key here is I want to plot the strians with "HI" as dashed lines and the others as solid lines, this gives me:
I then want to define my own colour schemes so the same strains have the same colour points and lines but the lines are dashed for the "HI" versions. I tried this:
cols1 <- c("M12-611025 (0)" = "blue",
"M12-611025 (0) HI" = "blue",
"M12-611025 (300)" = "#ff9700",
"M12-611025 (300) HI" = "#ff9700",
"M12-611025 (700)" = "#33d100",
"M12-611025 (700) HI" = "#33d100",
"M12-611025 (1100)" = "#fe0000",
"M12-611025 (1100) HI" = "#fe0000")
M12_611025 + scale_fill_manual(values = cols1)
This changes the points but not the lines, and I can not figure out how to get the lines the same colour as the points?