# Are the start and end values for the plt.hist() function's range parameter inclusive or exclusive?

### Question

In the context of this exercise, are the start and end values for the `plt.hist()` function’s `range` parameter inclusive or exclusive?

`plt.hist(data, range=(start, end))`

In a histogram, the start value data is inclusive, but the end value data is exclusive. In order to include the last value correctly, you can do
`plt.hist(data, range=(start, end+1))`
to include the end value.

Also, when determining the values for each bin in the histogram, there is an important difference regarding the range of values each one will use. For every bin in the histogram, except for the final bin, the range of values is
`[start_i, end_i)`
where `start_i` and `end_i` are the start and ending values for each bin.

`[` means inclusive of the start value, and `)` means exclusive of the end value.

The final bin in a histogram is inclusive of the end value,
`[start_i, end_i]`

For example, if we had 5 equally spaced bins from 0 to 5, each bin will include the data ranges as follows.
`[0, 1)`, `[1, 2)`, `[2, 3)`, `[3, 4)`, `[4, 5]`

3 Likes

Why do we plot the histogram in histogram.py and not script.py, unlike all other graphs drawn?

They did that for our better understanding. Yes we could have done that…but if you noted they imported data from that file for our convenience.

Any one knows how to load from the csv and plot the data exactly like the tutorial shows? I copied the data from sales_times and saved csv file loaded but always get different shape. Thanks.

Did you perform the same code from the script.py file on your data?

``````from matplotlib import pyplot as plt
import csv

def convert_time_to_num(time):
mins = int(time[-2:])
frac_of_hour = mins/60.0
hour = int(time[:-3])
time = hour + frac_of_hour
return time

sales_times_raw = []
with open('sales_times.csv') as csvDataFile: