这是我的数据(data.txt):
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11
T1 1.6 17 2.2 1 4.4 23.8 0.2 2.8 3.2 0.4 18.2
T2 0 3.5 1.5 0.5 4 3 6.5 21.6 0.5 1 18.6
T3 0 0 0 4.2 4.2 41.7 4.2 0 8.3 4.2 4.2
T4 4 0 0 0 0 12 4 4 4 16 20
T5 31.3 6.3 12.5 0 0 12.5 0 0 6.3 0 0
T6 12.5 0 0 18.8 0 12.5 0 0 6.3 6.3 0这是我的密码:
data = read.table("C:/Users/Irwan/Desktop/graph_plot/data.txt", header = TRUE, sep = "\t", row.names = 1)
attach(data)
column = colnames(data)
rows = rownames(data)
x = barplot(as.matrix(data), xaxt = "n", beside = TRUE, legend = rows, ylim = c(0, 50), density = c(30,30,30,30,70,100), angle = c(0,45,90,135,0,0))
label = as.vector(column)
text(x = x + 1.20, y = -1.25, xpd = TRUE, cex = 0.6, srt = 90, label, pos = 2)不幸的是,我无法正确地分组x轴标签.
我尝试了很多解决方案,到目前为止,我就是这样做的。有人能指导我如何将结果分组到每6条上(例如: S1表示前6条)。请在我的,我不是很好的R和我只能使用预装的R软件包,因为我不能安装任何新的软件包,由于未知的原因。谢谢。
已更新
我稍微修改了我的代码,这样就可以很容易地复制。我的新代码:
y = matrix (1:15, ncol = 5)
x = barplot(as.matrix(y), xaxt = "n", beside = TRUE, legend = c("T1","T2","T3"), ylim = c(0,30), density = c(30,30,30), angle = c(0,45,90))
label = rep(c("S1","S2","S3","S4","S5"), each = 3)
text(x = x + 0.4, y = -1.25, xpd = TRUE, cex = 0.6, srt = 90, label, pos = 2)发布于 2015-03-18 18:16:33
如果我正确地读到了你,把你的标签换成:
label = rep(column,each=6)应该提供想要的结果。
编辑;
如果每个组只需要一个标签
label = as.vector(rbind("",paste("S",1:5,sep=""),""))https://stackoverflow.com/questions/29120229
复制相似问题