Adjusting bar widths, spacing, colors, and borders
In this recipe, we will learn how to adjust the styling of bars by setting their width, the space between them, colors, and borders.
Getting ready
We will continue using the citysales.csv
example dataset in this recipe. Make sure that you have loaded it into R and type in the recipe at the R prompt. You might also want to save the recipe as a script so that you can easily run it again later.
How to do it...
Let's adjust all the arguments at once to make the same graph as in the Creating bar charts with more than one factor variable recipe but with different visual settings:
barplot(as.matrix(citysales[,2:4]), beside=TRUE, legend.text=citysales$City, args.legend=list(bty="n",horiz=T), col=c("#E5562A","#491A5B","#8C6CA8","#BD1B8A","#7CB6E4"), ...
Get R: Data Analysis and Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.