A python package to generate waffle plots. Originally inspired by this stack overflow question.
Related project: PyWaffle.
Code used to generate this example, based on examples from the R-based waffle library:
import pandas as pd
import wafflemaker
df = pd.DataFrame(dict(
values=[84911, 14414, 10062, 8565],
categories=[
'Mortgage ($85k)',
'Auto and tuition loans ($14k)',
'Home equity loans ($10k)',
'Credit cards ($9k)'
],
hues=["#c7d4b6", "#a3aabd", "#a0d0de", "#97b5cf"]
))
df['scaled_values'] = df['values'] / 500.
wafflemaker.waffle(
nrows=7,
scale_to_dims=False,
data=df,
values='scaled_values',
labels='categories',
hue='hues',
title='Average Household Debt',
grid_options=dict(linewidth=2),
figure_options=dict(figsize=(14, 5)),
)
For more examples, see the jupyter notebook.
To install the latest stable version, run this command in your terminal:
pip install -U wafflemaker
To install the development version:
git clone https://github.com/shapiromatron/wafflemaker
cd wafflemaker
pip install -e .
pip install -e .[test]
To run tests:
cd wafflemaker
py.test
Image comparisons from matplotlib use the pytest-mpl library. To create new baseline images for comparison:
py.test --mpl-generate-path=tests/baseline
Please submit tests with new feature requests.