Waffle chart
A Waffle Chart represents categorical data using a grid of equally sized squares or rectangles, each colored or shaded to depict different categories or segments.
Python enables the creation of waffle charts through the PyWaffle
library. This page offers numerous examples of charts built using the PyWaffle library, ranging from basic implementations to more advanced customizations.
⏱ Quick start
The PyWaffle library allows to build a waffle chart easily thanks to its Waffle
class.
The input data is a dictionary with names as keys and associated integer values.
The number of rows and columns can be set with the rows
and columns
arguments:
# useful libraries, including pyWaffle
import matplotlib.pyplot as plt
from pywaffle import Waffle
# create simple dummy data
data = {'Kevin': 10, 'Joseph': 7, 'Yan': 8}
# Basic waffle
plt.figure(
FigureClass=Waffle,
rows=5,
columns=20,
values=data,
legend={'loc': 'upper left', 'bbox_to_anchor': (1.05, 1)},
)
plt.show()
Pie chart with PyWaffle
The examples below should guide you through the Waffle
class usage. It starts with a very basic example and then provides hints on how to apply usual customization like using icons or showing percentages in the legend.
Contact
👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥