0

大家好! 我尝试结合箱线图和条形图来表示一些数据,并尝试按组着色:

XFACT YVAR无反应0.0012无反应0.0002无响应0.0018无反应0.0004无反应0.0013无反应0.0004无反应0.0029非反应0.0029非反应0.0016 0.0016响应0.0177响应0.0177响应0.035响应0.0335响应0.0335响应0.0335响应0.0118 0.0314

我的代码:

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) 

所以我希望绿色表示无响应,红色表示响应,而不是我有一些奇怪的输出: 我的输出

那么你能帮我按组(不响应和响应)而不是随机着色吗?

4

1 回答 1

0

这不是真正的解决方案,只是一种解决方法。

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) 

带有添加条形图的箱线图

于 2019-10-13T14:04:45.417 回答