# monthly histogram plots
from pandas import read_csv
from matplotlib import pyplot
# load the new file
dataset = read_csv('HondaHome2018_NET_POWER_Hourly.csv',
                   header=0, 
                   infer_datetime_format=True, 
                   parse_dates=['datetime'], 
                   index_col=['datetime'])


# plot active power for each year
months = [x for x in range(1, 13)]
pyplot.figure()
for i in range(len(months)):
    # prepare subplot
    ax = pyplot.subplot(len(months), 1, i+1)
    # determine the month to plot
    month = '2018-' + str(months[i])
    # get all observations for the month
    result = dataset.loc[month]
    # plot the active power for the month
    #Net_total,Lighting,HVAC,Appliances,Sun_altitude,
    #Air_Temp_outdoor,Air_Temp_room
    result['Lighting'].hist(bins=100)
    #result['HVAC'].hist(bins=100)
    # zoom in on the distribution
    ax.set_xlim(0, 7) # <--- Important to tune for each variable!!!
    # add a title to the subplot
    pyplot.title(month, y=0, loc='right')
pyplot.show()
