Dears,
I would like to add labels inside the bars of a horizontal bar
plot like this:
mylabels = c(
"long text goes here first",
"long text goes here second",
"long text goes here third",
"long text goes here fourth",
"long text goes here fourth",
"long text goes here fifth",
"long text goes here sixth",
"long text goes here seventh",
"long text goes here bla bla",
"long text goes here and more"
)
myvect1 = c(0.25,0.21,0.20,0.22,0.20,0.22,0.20,0.22,0.20,0.22)
myvect2 = c(0.13,0.08,0.09,0.11,0.13,0.08,0.09,0.11,0.13,0.08)
mydf = data.frame(myvect1,myvect2) # Forgive this df<->matrix mess, I
use the df for other stuff
barplot(t(as.matrix(mydf)),
horiz=TRUE,
beside=TRUE,
space=c(-0.9,0.1))
What I would like is to have the labels inside the upper bar.
Any ideas?
Bests,
Albert.
labels inside the bars of horizontal barplot
2 messages · Albert Vilella, Jacques VESLOT
b <- barplot(t(as.matrix(mydf)),horiz=TRUE,beside=TRUE,space=c(-0.9,0.1)) text(myvect1, b[1,], mylabels, col="white", adj=1) Albert Vilella a ??crit :
Dears,
I would like to add labels inside the bars of a horizontal bar
plot like this:
mylabels = c(
"long text goes here first",
"long text goes here second",
"long text goes here third",
"long text goes here fourth",
"long text goes here fourth",
"long text goes here fifth",
"long text goes here sixth",
"long text goes here seventh",
"long text goes here bla bla",
"long text goes here and more"
)
myvect1 = c(0.25,0.21,0.20,0.22,0.20,0.22,0.20,0.22,0.20,0.22)
myvect2 = c(0.13,0.08,0.09,0.11,0.13,0.08,0.09,0.11,0.13,0.08)
mydf = data.frame(myvect1,myvect2) # Forgive this df<->matrix mess, I
use the df for other stuff
barplot(t(as.matrix(mydf)),
horiz=TRUE,
beside=TRUE,
space=c(-0.9,0.1))
What I would like is to have the labels inside the upper bar.
Any ideas?
Bests,
Albert.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html