Python | Step Histogram Plot

Step Histogram Plot in Python. Here, we are going to learn about the step histogram plot and its Python implementation.
Submitted by Anuj Singh, on July 19, 2020

A histogram is a graphical technique or a type of data representation using bars of different heights such that each bar group's numbers into ranges (bins or buckets). Taller the bar higher the data falls in that bin. A Histogram is one of the most used techniques in data visualization and therefore, matplotlib has provided a function matplotlib.pyplot.hist() for plotting histograms. Step histogram is a type of histogram in which Bars are not filled with color, instead only the edge is the representation of Histogram. It is in a form of steps of stairs and therefore it is known as step histogram.

The following example illustrates the implementation and use of the Step Histogram Plot.

Python | Step Histogram Plot (1)

Python | Step Histogram Plot (2)

Python | Step Histogram Plot (3)

Python code for step histogram plot

import matplotlib.pyplot as plt
import numpy as np

# random data generation
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

# Histogram of the Data
plt.hist(x, 25, histtype='step')
plt.title('Step Histogram')

plt.hist(x, 15, density=1, histtype='step')
plt.title('Step Histogram : No. of Bins = 15')

plt.hist(x, 10, density=1, edgecolor='purple', linewidth=2.0, histtype='step')
plt.title('Step Histogram : Edge Width = 2.0')


Output is as figure

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.