I have some data as of below:
mydata <- rbind(c(5,4,3,7,6),
c(1,4,5,2,2))
colnames(mydata) <- c("Ali","Bala","Chun Li","Danny","Esther")
And I would like to do a grouped bar plot of my data:
x <- barplot(mydata, beside=T, las=2,
col=c("yellow2", "brown2"),
main="Chocolates Eaten by Students",
ylab="No. of chocolates")
legend("topright", cex=0.7,
legend = c("White", "Dark"),
fill = c("yellow2", "brown2"))
How can I rotate the x axis labels 45 degrees clockwise (from the current positions)?
Note: Using the following did not give me the output I want.
text(cex=1, x=x+0.5, y=0, colnames(mydata), xpd=TRUE, srt=45, pos=2)