This is my data (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
And this is my code:
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)
Unfortunately, I'm not able to group x-axis labels correctly.
I've try numbers of solution and this is what I get so far. Can anyone guide me on how to group the result on every 6 bars (example: S1 for the first 6 bars). Please bear in my that I'm not very good in R and I only able to use pre-installed R package as I cannot install any new package due to unknown reason. Thank you.
UPDATED
I have change little bit my code so that it might be easy to reproduce. My new code:
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)