barplot
retournera la position médiane de x des barres, pour que vous puissiez faire
mydata <- matrix(c(10, 21, 22, 33, 45, 23, 22, 43, 33), nrow=3)
# b will contain the x midpoints of the bars
b <- barplot(mydata)
# This will write labels in the middle of the bars, horizontally and vertically
text(b, colMeans(mydata), c("Label1", "Label2", "Label3"))
# This will write labels in the middle of the middle block
text(b, mydata[1,]+mydata[2,]/2, c("LabelA", "LabelB", "LabelC"))
EDIT: relisant votre question, je pense que c'est ce que vous voulez (ou peut-être pas, mais je vais l'écrire de toute façon: D)
# Find the top y position of each block
ypos <- apply(mydata, 2, cumsum)
# Move it downwards half the size of each block
ypos <- ypos - mydata/2
ypos <- t(ypos)
text(b, ypos, mydata)
texte
Salut Nico, wow cela fonctionne parfaitement bien avec les barplots verticaux.Merci beaucoup.Je suis heureux que la solution n'était pas si mystérieux.J'ai aussi essayé d'appliquer votre code à un barplot vertical ainsi Il suffit d'échanger b et ypos, beaucoup de mercis! – Jens