# -*- coding: utf-8 -*-
"""
Created on Sun Nov 14 12:46:21 2021

@author: Sim
"""
import numpy as np
import matplotlib.pyplot as plt

x = np.random.normal(size=1000)

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12,9))

ax1.hist(x)
ax2.hist(x, orientation='horizontal', density=True, 
         edgecolor='red', linewidth=1.2)

freq = [10, 30, 20, 40]
ax3.hist(x=np.arange(1.5,5.5), weights=freq)

## numpy
freqs, edges = np.histogram(a=x)
centre = edges[0:10] 
ax4.hist(x=centre,  bins=edges, weights=freqs, 
         edgecolor='#FFFFFF', linewidth=1.2)

labels = [str(e) for e in freqs]
for i in range(0, len(centre)):
    ax4.text(centre[i], freqs[i]+2, labels[i], color='red')
    
plt.show()
fig.savefig(r'd:/htex/Pythonbk/images/hist1.png')
plt.close()
