这是我用于绘制条形图的“计数”表(对不起,我不知道更好的方法来链接数据):
1 1.5 2 2.5 3 3.5
M8244 0 20 0 16 0 4
cp14 20 0 16 0 5 0
cp17 0 0 0 0 1 0
cp4 0 0 0 0 1 0
和我的代码:
barplot(counts, main="deadwood isolates",
xlab="sampling timepoint", ylab="samples obtained",ylim=c(0,21),
col=c("grey85","white","grey40","black"),space=c(1,0),
names.arg=c("fungus","CHV-1","fungus","CHV-1","fungus","CHV-1"),
offset=0,mgp=c(4,1,0)
)
legend = rownames(counts)
legend("topright",legend,fill=c("grey85","white","grey40","black"))
我在数据输入中使用1.5,2.5,3.5来欺骗出价,以便能够对条形图进行分组,因为使用beside
无法获得堆积的条形图。
我想用当前名称(真菌/ CHV-1)下面的“timepoint1”“timepoint2”和“timepoint3”标记分组条(1& 1.5; 2& 2.5; 3& 3.5)。
那可能吗?
提前感谢您的时间!
答案 0 :(得分:3)
您可以使用" \ n"为新线。
line1 <- c("fungus","CHV-1","fungus","CHV-1","fungus","CHV-1")
line2 <- paste0("timepoint", 1:6)
vector_names.arg <- paste(line1, line2, sep = "\n")