Skip to main content

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

Cleaning the Graph

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 polisher do the following:

Remove grid lines and background

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 polisher

polisher.remove_grids(figure=fig)
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.

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

Shortcut for commands below:

poetry run task publish

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 polisher

Testing

To test this project run:

poetry run task test

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 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.

Metadata

Release files for polisher 2.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polisher 2.0.4
File Size Uploaded Provenance Actions
polisher-2.0.4.tar.gz 8.1 kB Without provenance Details for polisher-2.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polisher 2.0.4
File Interpreter ABI Platform Actions
polisher-2.0.4-py3-none-any.whl Python 3 none any Details for polisher-2.0.4-py3-none-any.whl

Total release size: 15.3 kB

Release files / polisher-2.0.4.tar.gz

Download URL polisher-2.0.4.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
68964b1dc1f0efc63ae49a3e70ae3b8310d394d84e71c50a94c7980ae8a3f076
BLAKE2b-256 checksum
How to use checksums
9d6ec8d4533ac1f0519e6cfc70623ee44b3bfc1c3781aed6503f2f02e5ad86d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Release files / polisher-2.0.4-py3-none-any.whl

Download URL polisher-2.0.4-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
561bccfda1b3cf85024e97b28793eff004ad18b0c6073fc74fa75b34fd45fbf8
BLAKE2b-256 checksum
How to use checksums
8ca64a30d57206f0930e0d325cffcbf48c1695f62701f23b049bf3b8eee241d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4

Security for polisher 2.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page