June 2016
Beginner to intermediate
1783 pages
71h 22m
English
In this recipe, we will learn how to adjust the orientation of bars to horizontal or vertical.
We will use the same dataset we used in the last few recipes (citysales.csv) and the RColorBrewer color palette package.
Let's make a bar chart with horizontal bars:
barplot(as.matrix(citysales[,2:4]), beside=TRUE,horiz=TRUE, legend.text=citysales$City, args.legend=list(bty="n"), col=brewer.pal(5,"Set1"),border="white", xlim=c(0,100), xlab="Sales Revenue (1,000's of USD)", main="Sales Figures")

In the example, we set the horiz argument to TRUE, which makes ...
Read now
Unlock full access