Matplotlib/seaborn histogram using different colors for grouped bins
Solution:
N, bins, patches = plt.hist(df1['Average'], 30)
cmap = plt.get_cmap('jet')
low = cmap(0.5)
medium =cmap(0.2)
high = cmap(0.7)
for i in range(0,3):
patches[i].set_facecolor(low)
for i in range(4,13):
patches[i].set_facecolor(medium)
for i in range(14,30):
patches[i].set_facecolor(high)
plt.xlabel("Watt Hours", fontsize=16)
plt.ylabel("Households", fontsize=16)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
ax = plt.subplot(111)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
plt.show()
output: