Skip to main content

graph-polisher is a library that helps you clean your plotly figures.. This library is inspired by the book Storytelling with Data by Cole Nussbaumer Knaflic (https://www.kobo.com/us/en/ebook/storytelling-with-data).

Project description

graph-polisher

PyPI version build status coverage report Code style: mypy PyPI - License

[[TOC]]

Graph polisher is a library that helps you clean your plotly figures. This library was inspired by the book "Storytelling with Data by Cole Nussbaumer Knaflic (https://www.kobo.com/us/en/ebook/storytelling-with-data).

Usage

To start our graph polishing, we will create a basic bar graph:

import pandas as pd
import plotly.express as px

report_data = [
    {'name': 'Time Sheets', 'exported': 394},
    {'name': 'Schedules', 'exported': 171},
    {'name': 'overtime', 'exported': 457},
    {'name': 'Time-off', 'exported': 93},
    {'name': 'Shift Requests', 'exported': 30},
]
df = pd.DataFrame(report_data)

fig = px.bar(df, title='Exported Reports', x='name', y='exported')

fig.show()

Raw Bar Plot

Next, we will remove all the unnecessary information from the graph. By removing unnecessary things from the graph, we will then be able to focus on important information that will help us drive the user to where we want them to focus on.

To remove all that default unnecessary information with graph-polisher do the following:

Remove grid lines and brackground

Grid lines usually compete with the information being shown. If you really think that you should include them, make them thin and grey so it doesn't call attention.

import graph_polisher

graph_polisher.remove_grids(figure=fig)
graph_polisher.remove_background(figure=fig) 

fig.show()

Bar No Grid Plot

Send to background

The dark colors (black text, bold text) of the graph also calls for attention. We can easily make them less attention grabbing by sending them to the background. Sending them to the background will set the text color to a more neutral color like grey.

graph_polisher.send_to_background(fig)

fig.show()

Send to backgroung

Notice the difference between the default bar graph and our new version.

Default Bar Plot No Distractions Bar Plot
Raw Bar Plot Send to backgroung

Now you have a graph that you can easily add intentional attention grabbing information so that your user is guided through the information you are trying to present.

Deploying pip library

Build the pip library package to deploy to pip:

python3 setup.py sdist bdist_wheel

Publish to pip. You can follow steps here

Note that you will need to install twine and register your pypi. Usually in the file ~/.pypirc

python3 -m twine upload --repository pypi dist/*

Installation

pip install graph-polisher

Testing

To test this project run:

pytest

Notebook Example (with unnotebook)

Prerequisite: https://www.docker.com/

You can use this to see how the library modifies the plots. We are using unnotebook to plot the examples.

  1. Build and push notebook image:
docker build . -t graph-polisher
  1. Run notebook
docker-compose up notebook

or

docker run --rm -it \
    -v /Users/rigo/Documents/Projects/notebooks/stock-predictions:/notebooks \
    -p 8899:8899 unclutterer
  1. Open http://localhost:8899/ and open the notebook you want to run.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph-polisher-1.0.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_polisher-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file graph-polisher-1.0.0.tar.gz.

File metadata

  • Download URL: graph-polisher-1.0.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for graph-polisher-1.0.0.tar.gz
Algorithm Hash digest
SHA256 77d8fee9aa80145d3f1defd6c4a70188124d3ab1e1442a674bd4e0bdb5e9ca8b
MD5 c89e15dbb1d45c0cc9461899c79eb406
BLAKE2b-256 aa42619fc42ae2cc227a589ffbd01f2113c1ac5110dbd3748f6500b6bfd41e15

See more details on using hashes here.

File details

Details for the file graph_polisher-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: graph_polisher-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for graph_polisher-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 746d7702dd11ec229988a64b083d45be6101179b3ead545291a029e595d9bf4b
MD5 b77f9ea73f38766a4e82d8e0bd2b5bb8
BLAKE2b-256 e892d6085fa158dac17fba39932802b00ea658a43ea3515623ec34854edae6ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page