Reputation: 345
I've tried to add values from my vector to the right of my horizontal bar plots without success. I've tried to fix and mix some code as well on my x and y labels and its placements. Here is my code
a <- c(315, 149, 128, 97, 68, 49, 38, 0)
par(las=1)
par(mgp=c(4.5,1,0))
par(mar=c(5,6,4,3)+0.05)
barplot(a, horiz = TRUE, col="darkolivegreen3",
main="Average Occupancy",
ylab = "Hours",
names.arg = c("0-1h", "1-2h", "2-3h", "3-4h", "4-5h", "5-6h", "6-7h", "7-8h"))
mtext(side=1, text="Minutes", line=2.5)
Upvotes: 0
Views: 2556
Reputation: 24252
Here is the code for your graph.
a <- c(315, 149, 128, 97, 68, 49, 38, 0)
par(mar=c(4,4,1,1), oma=c(0,0,0,0), las=1)
posbar <- barplot(a, horiz = TRUE, col="darkolivegreen3",
main="Average Occupancy",
ylab = "", xlab="", xlim=c(0,350),
names.arg = c("0-1h", "1-2h", "2-3h", "3-4h", "4-5h", "5-6h", "6-7h", "7-8h"))
mtext(side=1, text="Minutes", line=2.5)
mtext(side=2, text="Hours", line=3, las=0)
text(y=posbar, x=a, pos=4,labels=a)
Upvotes: 1