Creating stack plot - Python Mathplotlib Module

Creating stack plot - Python Mathplotlib Module

Instructor-svgAl-Mamun Sarkar
Apr 02 , 2020

Creating stack plot - Python Mathplot Module. The following codes show how to plot Stack graph using python mathplotlib module.

 

 

Import Module:

import matplotlib.pyplot as plt

 

Create Data:

days_data = [1,2,3,4,5]

sleeping_data = [7,8,6,11,7]
eating_data =   [2,3,4,3,2]
working_data =  [7,8,7,2,2]
playing_data =  [8,5,7,8,13]

 

Plot Stack Graph:

plt.stackplot(days_data, sleeping_data, eating_data, working_data, playing_data, colors=['m', 'c', 'r', 'k'])
plt.title("Welcome to stack plotting tutorial")
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.show()

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram