Generate Waffle chart using pyWaffle in Python

A Waffle Chart is a gripping visualization technique that is normally created to display progress towards goals. Where each cell in the Waffle Chart constitutes of 10 X 10 cell grid in which each cell represents one percentage point summing up to total 100%. It is commonly an effective option when you are trying to add interesting visualization features to a visual. Waffle Charts are widely used as an Excel dashboard.

For generating Waffle Chart in Python, modules needed are – matplotlib, pandas and pyWaffle.
To install these packages, run the following commands :

pip install matplotlib
pip install pandas
pip install pywaffle

Below is the implementation:

filter_none

edit
close

play_arrow

link
brightness_4
code

# python program to generate Waffle Chart
  
# importing all necessary requirements
import pandas as pd
import matplotlib.pyplot as plt
from pywaffle import Waffle
  
# creation of a dataframe
data ={'phone': ['Xiaomi', 'Samsung',
                 'Apple', 'Nokia', 'Realme'],
       'stock': [44, 12, 8, 5, 3]
     }
  
df = pd.DataFrame(data)
  
# To plot the waffle Chart
fig = plt.figure(
    FigureClass = Waffle,
    rows = 5,
    values = df.stock,
    labels = list(df.phone)
)

chevron_right


Output:
Waffle chart using pyWaffle
The above Waffle Chart has been generated for the data in the DataFrame

Advantages:

  • More visually attractive.
  • Used for attractive Dashboards.

Disadvantages:

  • Waffle Chart becomes too complicated when too many segments are involved.
  • individualized spaces do not leave a spot to put numbers or text within the visual itself.
My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.