我有两组数据(顶部和底部),我已经能够单独制作箱图,但无法让它们显示在同一图表中。我希望它们并排进行每个基因测试的比较(总共12个)。所以,我想用测试的基因标记x轴,用ddCt值标记y轴,每个基因有2个箱图(顶部1个,底部1个)。我在下面分别为每个代码编写代码:
# boxplot of first group
boxplot(Top25[-1], main = "Top Performers Gene Expression Relative to 16S", ylab = "ddCt Values", xlab = "Biofilm Gene", cex.axis = 0.75)
# boxplot of second group
boxplot(Bottom25 [-1], main = "Bottom Performers Biofilm Gene Expression Relative to 16S", ylab = "ddCt Values", xlab = "Biofilm Gene", cex.axis = 0.75)
对于我可能尝试的任何建议?我试图"融化"他们一起关注另一个ggplot2问题并得到一个错误说"没有找到对象熔化"。谢谢你的帮助!
答案 0 :(得分:0)
这是一个例子。主要想法是使用add = TRUE
将boxplot
添加到现有绘图中,并使用at
指定boxplot的水平位置
#DATA
set.seed(42)
top = rnorm(40)
bottom = rnorm(40)
#Create Empty Plot
plot(1, 1, type = "n", xlim = c(0, 3), ylim = range(c(top, bottom)),
ann = FALSE, xaxt = "n")
#Add boxplots to existing plot
boxplot(x = top, at = 1, add = TRUE)
boxplot(x = bottom, at = 2, add = TRUE)
axis(1, at = c(1, 2), labels = c("top", "bottom"))
答案 1 :(得分:0)