├── .gitattributes ├── setup.cfg ├── .gitignore ├── roughviz ├── __init__.py ├── templates │ ├── donut.html │ ├── pie.html │ ├── stackedbar.html │ ├── bar.html │ └── barh.html └── roughviz.py ├── .github └── workflows │ ├── pythonpublish.yml │ └── pythonpackage.yml ├── LICENSE ├── setup.py ├── README.md ├── CODE_OF_CONDUCT.md └── roughviz example.ipynb /.gitattributes: -------------------------------------------------------------------------------- 1 | *.* linguist-language=Python 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | license_file = LICENSE -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | roughviz.egg-info 4 | -------------------------------------------------------------------------------- /roughviz/__init__.py: -------------------------------------------------------------------------------- 1 | """A visualization library for creating sketchy/hand-drawn styled charts.""" 2 | 3 | from .roughviz import ( 4 | bar, 5 | barh, 6 | pie, 7 | donut, 8 | stackedbar 9 | ) 10 | -------------------------------------------------------------------------------- /.github/workflows/pythonpublish.yml: -------------------------------------------------------------------------------- 1 | name: Upload Python Package 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Set up Python 13 | uses: actions/setup-python@v1 14 | with: 15 | python-version: '3.x' 16 | - name: Install dependencies 17 | run: | 18 | python -m pip install --upgrade pip 19 | pip install setuptools wheel twine 20 | - name: Build and publish 21 | env: 22 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 23 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 24 | run: | 25 | python setup.py sdist bdist_wheel 26 | twine upload dist/* 27 | -------------------------------------------------------------------------------- /.github/workflows/pythonpackage.yml: -------------------------------------------------------------------------------- 1 | name: Python package 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | strategy: 10 | max-parallel: 4 11 | matrix: 12 | python-version: [3.6, 3.7] 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Set up Python ${{ matrix.python-version }} 17 | uses: actions/setup-python@v1 18 | with: 19 | python-version: ${{ matrix.python-version }} 20 | - name: Install dependencies 21 | run: | 22 | python -m pip install --upgrade pip 23 | - name: Lint with flake8 24 | run: | 25 | pip install flake8 26 | # stop the build if there are Python syntax errors or undefined names 27 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 28 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 29 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Hannan Satopay 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | with open("README.md", "r") as fh: 4 | long_description = fh.read() 5 | 6 | package_data = { 7 | '': [ 8 | './templates/*.html', 9 | ] 10 | } 11 | 12 | setuptools.setup( 13 | name="roughviz", 14 | version="4.7.0", 15 | author="Hannan Satopay", 16 | author_email="sathannan@hotmail.com", 17 | description="A python visualization library for creating sketchy/hand-drawn styled charts.", 18 | long_description=long_description, 19 | long_description_content_type="text/markdown", 20 | license="MIT", 21 | url="https://github.com/hannansatopay/roughviz", 22 | packages=setuptools.find_packages(), 23 | install_requires=['Jinja2','pandas'], 24 | package_data=package_data, 25 | classifiers=[ 26 | "Development Status :: 5 - Production/Stable", 27 | "Framework :: IPython", 28 | "Programming Language :: Python :: 3", 29 | "License :: OSI Approved :: MIT License", 30 | "Operating System :: OS Independent", 31 | ], 32 | python_requires='>=3.6', 33 | ) 34 | -------------------------------------------------------------------------------- /roughviz/templates/donut.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /roughviz/templates/pie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /roughviz/templates/stackedbar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /roughviz/templates/bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /roughviz/templates/barh.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # roughviz 2 | 3 |  4 | 5 | roughviz is a python visualization library for creating sketchy/hand-drawn styled charts. 6 | 7 | [](https://github.com/hannansatopay) 8 | 9 | ### Available Charts 10 |roughviz.bar) roughviz.barh) roughviz.pie) roughviz.donut) roughviz.stackedbar)
45 |
46 | ### License
47 | [](https://opensource.org/licenses/MIT)
48 |
49 | Copyright (c) 2019 Hannan Satopay
50 |
--------------------------------------------------------------------------------
/roughviz/roughviz.py:
--------------------------------------------------------------------------------
1 | from jinja2 import Template
2 | from IPython.core.display import display, HTML
3 | import random
4 | import string
5 | import json
6 | import pkgutil
7 | import pandas as pd
8 |
9 |
10 | def generate_template(data, labels, values, plot_svg, **kwargs):
11 | template = Template(data.decode("utf-8"))
12 | id_name = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
13 | output = template.render(id_name = id_name,
14 | labels = labels,
15 | values = values,
16 | kwargs = kwargs)
17 | if(plot_svg):
18 | svg_id = "svg"+id_name
19 | script = """
20 |
25 |
40 | """
41 | display(HTML(output))
42 | display(HTML(script))
43 | else:
44 | display(HTML(output))
45 |
46 | def bar(labels, values, plot_svg = False, **kwargs):
47 | data = pkgutil.get_data(__package__, 'templates/bar.html')
48 | generate_template(data, labels.tolist(), values.tolist(), plot_svg, **kwargs)
49 |
50 | def barh(labels, values, plot_svg = False, **kwargs):
51 | data = pkgutil.get_data(__package__, 'templates/barh.html')
52 | generate_template(data, labels.tolist(), values.tolist(), plot_svg, **kwargs)
53 |
54 | def pie(labels, values, plot_svg = False, **kwargs):
55 | data = pkgutil.get_data(__package__, 'templates/pie.html')
56 | generate_template(data, labels.tolist(), values.tolist(), plot_svg, **kwargs)
57 |
58 | def donut(labels, values, plot_svg = False, **kwargs):
59 | data = pkgutil.get_data(__package__, 'templates/donut.html')
60 | generate_template(data, labels.tolist(), values.tolist(), plot_svg, **kwargs)
61 |
62 | def stackedbar(labels, values, plot_svg = False, **kwargs):
63 | data = pkgutil.get_data(__package__, 'templates/stackedbar.html')
64 | content = []
65 | for index, row in pd.concat([labels,values],axis=1).iterrows():
66 | content.append(row.to_dict())
67 | generate_template(data, labels.name, content, plot_svg, **kwargs)
68 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at sathannan@hotmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/roughviz example.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# INSTALL"
8 | ]
9 | },
10 | {
11 | "cell_type": "code",
12 | "execution_count": 1,
13 | "metadata": {},
14 | "outputs": [
15 | {
16 | "name": "stdout",
17 | "output_type": "stream",
18 | "text": [
19 | "Collecting roughviz\n",
20 | " Downloading https://files.pythonhosted.org/packages/a8/47/88e35b87730dd9c7ebb6807b8acbede6b1183f4c95cd7fb3e4a37f91b20b/roughviz-4.6.0-py3-none-any.whl\n",
21 | "Requirement already satisfied: Jinja2 in /opt/conda/envs/Python36/lib/python3.6/site-packages (from roughviz) (2.10)\n",
22 | "Requirement already satisfied: pandas in /opt/conda/envs/Python36/lib/python3.6/site-packages (from roughviz) (0.24.1)\n",
23 | "Requirement already satisfied: MarkupSafe>=0.23 in /opt/conda/envs/Python36/lib/python3.6/site-packages (from Jinja2->roughviz) (1.1.0)\n",
24 | "Requirement already satisfied: pytz>=2011k in /opt/conda/envs/Python36/lib/python3.6/site-packages (from pandas->roughviz) (2018.9)\n",
25 | "Requirement already satisfied: numpy>=1.12.0 in /opt/conda/envs/Python36/lib/python3.6/site-packages (from pandas->roughviz) (1.15.4)\n",
26 | "Requirement already satisfied: python-dateutil>=2.5.0 in /opt/conda/envs/Python36/lib/python3.6/site-packages (from pandas->roughviz) (2.7.5)\n",
27 | "Requirement already satisfied: six>=1.5 in /opt/conda/envs/Python36/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas->roughviz) (1.12.0)\n",
28 | "Installing collected packages: roughviz\n",
29 | "Successfully installed roughviz-4.6.0\n"
30 | ]
31 | }
32 | ],
33 | "source": [
34 | "!pip install roughviz"
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "# IMPORT"
42 | ]
43 | },
44 | {
45 | "cell_type": "code",
46 | "execution_count": 26,
47 | "metadata": {},
48 | "outputs": [],
49 | "source": [
50 | "import roughviz"
51 | ]
52 | },
53 | {
54 | "cell_type": "markdown",
55 | "metadata": {},
56 | "source": [
57 | "# VISUALIZE"
58 | ]
59 | },
60 | {
61 | "cell_type": "markdown",
62 | "metadata": {},
63 | "source": [
64 | "### BAR CHART"
65 | ]
66 | },
67 | {
68 | "cell_type": "code",
69 | "execution_count": 29,
70 | "metadata": {},
71 | "outputs": [
72 | {
73 | "data": {
74 | "text/html": [
75 | "\n",
76 | "\n",
77 | "\n",
90 | "\n",
91 | "\n",
92 | "\n",
93 | "\n",
94 | "\n",
95 | "\n",
96 | "\n",
134 | "\n",
135 | "\n",
136 | ""
137 | ],
138 | "text/plain": [
139 | "