Hi everyone! I try combined boxplot and stripchart to represent some data, and trying to color by group:
xfact yvar Non-response 0.0012 Non-response 0.0002 Non-response 0.0018 Non-response 0.0004 Non-response 0.0013 Non-response 0.0004 Non-response 0.0029 Non-response 0.0016 Response 0.0177 Response 0.0335 Response 0.0118 Response 0.0309 Response 0.0314 Response 0.0135
That my code:
boxplot(yvar~xfact, data = my.data, ylab= "CD8/GAPDH relative expression",
names = c("Non-response n=14", "Response n=6"), outpch =NA)
stripchart(yvar~xfact, data = my.data, vertical = TRUE, method =
"overplot", pch = 21, col = "black", bg = c("green", "red"), add= TRUE)
So I expect colored green for non-response and red for response, instead I have some weird output: my output
So can your help me to color by group(non-response and response) not randomly?
This is not really a solution, only a work-around.
Assigning a color (col
) by group works, so you could use
boxplot(yvar~xfact, data = my.data, ylab= "CD8/GAPDH relative expression",
names = c("Non-response n=14", "Response n=6"), outpch =NA)
stripchart(yvar~xfact, data = my.data, vertical = TRUE,
method = "overplot", pch = 16, col = c("green", "red"), add = T)
If you really want to get the appearance of a circle with a border, you can add the border separately.
boxplot(yvar~xfact, data = my.data, ylab= "CD8/GAPDH relative expression",
names = c("Non-response n=14", "Response n=6"), outpch =NA)
stripchart(yvar~xfact, data = my.data, vertical = TRUE,
method = "overplot", pch = 16, col = c("green", "red"), add = T)
stripchart(yvar~xfact, data = my.data, vertical = TRUE,
method = "overplot", pch = 21, col="black", add = T)