All Projects โ†’ gyli โ†’ Pywaffle

gyli / Pywaffle

Licence: mit
๐Ÿง‡ Make Waffle Charts in Python.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pywaffle

Keen Dataviz.js
Data Visualization Charting Library
Stars: โœญ 215 (-47.04%)
Mutual labels:  data-visualization, charts
PandasVersusExcel
Pythonๆ•ฐๆฎๅˆ†ๆžๅ…ฅ้—จ๏ผŒๆ•ฐๆฎๅˆ†ๆžๅธˆๅ…ฅ้—จ
Stars: โœญ 120 (-70.44%)
Mutual labels:  charts, matplotlib
Edaviz
edaviz - Python library for Exploratory Data Analysis and Visualization in Jupyter Notebook or Jupyter Lab
Stars: โœญ 220 (-45.81%)
Mutual labels:  data-visualization, matplotlib
Python Novice Inflammation
Programming with Python
Stars: โœญ 199 (-50.99%)
Mutual labels:  data-visualization, matplotlib
Victory Chart
Chart Component for Victory
Stars: โœญ 286 (-29.56%)
Mutual labels:  data-visualization, charts
Dexplot
Simple plotting library that wraps Matplotlib and integrated with DataFrames
Stars: โœญ 208 (-48.77%)
Mutual labels:  data-visualization, matplotlib
Matplotlib Cheatsheet
Matplotlib 3.1 cheat sheet.
Stars: โœญ 2,806 (+591.13%)
Mutual labels:  data-visualization, matplotlib
Graphic
A Flutter data visualization library based on Grammar of Graphics.
Stars: โœญ 173 (-57.39%)
Mutual labels:  data-visualization, charts
Ej2 Javascript Ui Controls
Syncfusion JavaScript UI controls library offer more than 50+ cross-browser, responsive, and lightweight HTML5 UI controls for building modern web applications.
Stars: โœญ 256 (-36.95%)
Mutual labels:  data-visualization, charts
nodeplotlib
NodeJS plotting library for JavaScript and TypeScript. On top of plotly.js. Inspired by matplotlib.
Stars: โœญ 115 (-71.67%)
Mutual labels:  charts, matplotlib
Elastic Charts
๐Ÿ“Š Elastic Charts library
Stars: โœญ 191 (-52.96%)
Mutual labels:  data-visualization, charts
Joypy
Joyplots in Python with matplotlib & pandas ๐Ÿ“ˆ
Stars: โœญ 322 (-20.69%)
Mutual labels:  data-visualization, matplotlib
Plotly.js
Open-source JavaScript charting library behind Plotly and Dash
Stars: โœญ 14,268 (+3414.29%)
Mutual labels:  data-visualization, charts
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) ๐Ÿ“ˆ๐Ÿ“Š
Stars: โœญ 199 (-50.99%)
Mutual labels:  data-visualization, charts
Matplotlib Doc Zh
๐Ÿ“– [่ฏ‘] Matplotlib ็”จๆˆทๆŒ‡ๅ—
Stars: โœญ 178 (-56.16%)
Mutual labels:  data-visualization, matplotlib
Reaviz
๐Ÿ“Š Data visualization library for React based on D3
Stars: โœญ 215 (-47.04%)
Mutual labels:  data-visualization, charts
Ej2 Angular Ui Components
Syncfusion Angular UI components library offer more than 50+ cross-browser, responsive, and lightweight angular UI controls for building modern web applications.
Stars: โœญ 159 (-60.84%)
Mutual labels:  data-visualization, charts
Matplotplusplus
Matplot++: A C++ Graphics Library for Data Visualization ๐Ÿ“Š๐Ÿ—พ
Stars: โœญ 2,433 (+499.26%)
Mutual labels:  data-visualization, charts
matplotlib-haskell
Haskell bindings for Python's Matplotlib
Stars: โœญ 80 (-80.3%)
Mutual labels:  charts, matplotlib
Anychart
AnyChart is a lightweight and robust JavaScript charting solution with great API and documentation. The chart types and unique features are numerous, the library works easily with any development stack.
Stars: โœญ 288 (-29.06%)
Mutual labels:  data-visualization, charts

PyWaffle

PyPI version ReadTheDocs Binder

PyWaffle is an open source, MIT-licensed Python package for plotting waffle charts.

It provides a Figure constructor class Waffle, which could be passed to matplotlib.pyplot.figure and generates a matplotlib Figure object.

PyPI Page: https://pypi.org/project/pywaffle/

Documentation: http://pywaffle.readthedocs.io/

Installation

pip install pywaffle

Requirements

  • Python 3.5+
  • Matplotlib

Examples

1. Value Scaling

import matplotlib.pyplot as plt
from pywaffle import Waffle
fig = plt.figure(
    FigureClass=Waffle, 
    rows=5, 
    columns=10, 
    values=[48, 46, 6],
    figsize=(5, 3)
)
plt.show()

basic

The values are automatically scaled to 24, 23 and 3 to fit 5 * 10 chart size.

2. Values in dict & Auto-sizing

data = {'Democratic': 48, 'Republican': 46, 'Libertarian': 3}
fig = plt.figure(
    FigureClass=Waffle, 
    rows=5, 
    values=data, 
    legend={'loc': 'upper left', 'bbox_to_anchor': (1.1, 1)}
)
plt.show()

Use values in dictionary; use absolute value as block number, without defining columns

In this example, since only rows is specified and columns is empty, absolute values in values are used as block numbers. Similarly, rows could also be optional if columns is specified.

If values is a dict, its keys are used as labels.

3. Title, Legend, Colors, Background Color, Block Color, Direction and Style

data = {'Democratic': 48, 'Republican': 46, 'Libertarian': 3}
fig = plt.figure(
    FigureClass=Waffle, 
    rows=5, 
    values=data, 
    colors=["#232066", "#983D3D", "#DCB732"],
    title={'label': 'Vote Percentage in 2016 US Presidential Election', 'loc': 'left'},
    labels=[f"{k} ({v}%)" for k, v in data.items()],
    legend={'loc': 'lower left', 'bbox_to_anchor': (0, -0.4), 'ncol': len(data), 'framealpha': 0},
    starting_location='NW',
    block_arranging_style='snake'
)
fig.set_facecolor('#EEEEEE')
plt.show()

Add title, legend and background color; customize the block color

Many parameters, like title and legend, accept the same parameters as in Matplotlib.

4. Plot with Icons - Pictogram Chart

data = {'Democratic': 48, 'Republican': 46, 'Libertarian': 3}
fig = plt.figure(
    FigureClass=Waffle, 
    rows=5, 
    values=data, 
    colors=["#232066", "#983D3D", "#DCB732"],
    legend={'loc': 'upper left', 'bbox_to_anchor': (1, 1)},
    icons='child', 
    font_size=12, 
    icon_legend=True
)
plt.show()

Use Font Awesome icons

PyWaffle supports Font Awesome icons in the chart.

5. Multiple Plots in One Chart

import pandas as pd
data = pd.DataFrame(
    {
        'labels': ['Hillary Clinton', 'Donald Trump', 'Others'],
        'Virginia': [1981473, 1769443, 233715],
        'Maryland': [1677928, 943169, 160349],
        'West Virginia': [188794, 489371, 36258],
    },
).set_index('labels')

# A glance of the data:
#                  Maryland  Virginia  West Virginia
# labels                                            
# Hillary Clinton   1677928   1981473         188794
# Donald Trump       943169   1769443         489371
# Others             160349    233715          36258


fig = plt.figure(
    FigureClass=Waffle,
    plots={
        '311': {
            'values': data['Virginia'] / 30000,
            'labels': [f"{k} ({v})" for k, v in data['Virginia'].items()],
            'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.05, 1), 'fontsize': 8},
            'title': {'label': '2016 Virginia Presidential Election Results', 'loc': 'left'}
        },
        '312': {
            'values': data['Maryland'] / 30000,
            'labels': [f"{k} ({v})" for k, v in data['Maryland'].items()],
            'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.2, 1), 'fontsize': 8},
            'title': {'label': '2016 Maryland Presidential Election Results', 'loc': 'left'}
        },
        '313': {
            'values': data['West Virginia'] / 30000,
            'labels': [f"{k} ({v})" for k, v in data['West Virginia'].items()],
            'legend': {'loc': 'upper left', 'bbox_to_anchor': (1.3, 1), 'fontsize': 8},
            'title': {'label': '2016 West Virginia Presidential Election Results', 'loc': 'left'}
        },
    },
    rows=5,  # outside parameter applied to all subplots
    colors=["#2196f3", "#ff5252", "#999999"],  # outside parameter applied to all subplots
    figsize=(9, 5)
)
plt.show()

Multiple plots

In this chart, 1 block = 30000 votes.

Data source https://en.wikipedia.org/wiki/United_States_presidential_election,_2016.

Demo

Wanna try it yourself? There is Online Demo!

What's New

See CHANGELOG

License

  • PyWaffle is under MIT license, see LICENSE file for the details.
  • The Font Awesome font is licensed under the SIL OFL 1.1: http://scripts.sil.org/OFL
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].