Matplotlib > Histograms

Name
Code
Output
gaussian = numpy.random.normal(loc=1.0, scale=0.1,size = 1000)
matplotlib.pyplot.hist(gaussian)
matplotlib.pyplot.show()

       
           Histogram (basic)
       
    
# Data
gaussian = numpy.random.normal(loc=1.0, scale=0.1,size = 10000)
# New Figure
fig = matplotlib.pyplot.figure(figsize=(7,4),facecolor='silver')
# New Axes
ax = fig.add_subplot(111,facecolor='azure')
# Add grid
ax.grid(color='b', linestyle='-', linewidth=0.5)
# set ticks
ax.xaxis.set_ticks(numpy.arange(min(x), max(x)+1, 1.0))
# Plot the data
ax.hist(gaussian,bins=50,color='orange')
ax.set(title="Plot title", xlabel="x axis", ylabel="y axis")
# Fit the plot layout
matplotlib.pyplot.tight_layout()
# Show the plot
matplotlib.pyplot.show()

       
           Histogram (customized)