Adjusting histogram styles – bar colors, borders, and axes

The default styling of histograms does not look great and might not be suitable for publications. In this recipe, we will learn how to improve the look by setting bar colors and borders, and adjusting the axes.

Getting ready

Once again we will use the airpollution.csv example. So, let's make sure it is loaded by running the following command at the R prompt:

air<-read.csv("airpollution.csv")

How to do it...

Let's visualize the probability distribution of respirable particle concentrations with black bars and white borders:

hist(air$Respirable.Particles, prob=TRUE,col="black",border="white", xlab="Respirable Particle Concentrations", main="Distribution of Respirable Particle Concentrations") ...

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.