A histogram includes an accurate representation of the distribution of numerical data. It includes a rough estimation of the probability distribution with the continuous variable. It differs from a bar graph. A bar graph compares two variables, and a histogram just one. In this section, we will focus on the use of histogram plots and how to draw and customize them. The iris dataset includes fewer attributes, so we can customize them as and when required.
Before understanding the customization of histograms with ggplot2, we should understand the normal plotting of the iris dataset. The difference between normal plotting and the plots created with ggplot2 will be clearly visible from the output screenshots.
The following command is executed to create a normal histogram:
> hist(iris$Sepal.Width, freq=NULL, density=NULL, breaks=12,
+ xlab="Sepal Width"...