In my previous posts, we have seen how we can plot stacked histogram (filled) and a stacked bar graph. In this post, we will see how we can plot a stacked Step histogram (unfilled) using Python’s Matplotlib library.

Basically, Histograms are a graphical representation of a frequency distribution of numerical data and it’s a great visualizing tool for quickly assessing a probability distribution of a continuous variable (quantitative variable). In a histogram, rectangles with equal sizes in the horizontal directions have heights with the corresponding frequencies.

**First** of all, to create any type of histogram whether it’s a simple histogram or a stacked histogram, we need to import libraries that will help us to implement our task.

Below are the two libraries Numpy and Matplotlib which helps us to perform our task:

import numpy as np from Matplotlib.pyplot as plt

**Let’s plot Stacked Step histogram (unfilled) using Python’s Matplotlib library:**

The below code will create the stacked step histogram (unfilled) using Python’s Matplotlib library. To plot, we have to pass the parameter** stacked = True** in the **plt.hist()** which informs Matplotlib library to perform the stacking task and we have to pass** fill=False** so that it can be shown unfilled in a form of steps. Have a look at the below code:

n_bins=30 x = np.random.randn(1000, 3) colors = ['blue', 'orange', 'green'] plt.hist(x, n_bins, histtype='step', stacked=True, fill=False, label=colors) plt.legend(loc="upper right") plt.title('Stack Step (unfilled)') plt.show()

Hope you like my post. To learn more about Matplotlib package, you can go through the official documentation here.

## Leave a Reply