按组添加颜色
Added 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
我的代码:
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)
所以我希望绿色表示无响应,红色表示响应,但我得到了一些奇怪的输出:
my output
所以你能帮我不随机地按组(无反应和反应)涂色吗?
这不是真正的解决方案,只是一种变通方法。
按组分配颜色 (col
),因此您可以使用
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)
如果你真的想得到一个带边框的圆的外观,你可以单独添加边框。
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)
大家好! 我尝试组合箱线图和带状图来表示一些数据,并尝试按组着色:
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
我的代码:
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)
所以我希望绿色表示无响应,红色表示响应,但我得到了一些奇怪的输出: my output
所以你能帮我不随机地按组(无反应和反应)涂色吗?
这不是真正的解决方案,只是一种变通方法。
按组分配颜色 (col
),因此您可以使用
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)
如果你真的想得到一个带边框的圆的外观,你可以单独添加边框。
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)