Histograms in Python
In this example, I am going to use a dataset from Kaggle on house sales in King County, USA (URL: https://www.kaggle.com/harlfoxem/housesalesprediction; accessed 28th August 2016).
Creating a histogram:
Specifying the number of bins
You can easily specify the number of bins by passing the argument:
bins = number
Changing the range
You can change the range by passing the argument of:
range = [min_number, max_number]
In my example, I want to visualise only the prices from 0 to 2,000,000.
Adding histogram titles and axis names
Adding the title of the histogram:
Naming the x axis:
Naming the y axis:
Changing the orientation
The default orientation of the histogram is vertical. You can change it to horizontal by passing the argument:
orientation = ‘horizontal’
Changing the transparency
You can change how transparent the histogram is by adding the argument ‘alpha’ with values between 0 to 1. 1 is the default value.
Changing colours requires the ‘color’ argument.