| Name | polisher JSON |
| Version |
2.0.4
JSON |
| download |
| home_page | https://gitlab.com/rigogsilva/polisher |
| Summary | 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). |
| upload_time | 2022-12-20 20:14:28 |
| maintainer | |
| docs_url | None |
| author | Rodrigo da Silva |
| requires_python | >=3.6 |
| license | MIT |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# polisher
[](https://pypi.org/project/polisher/)
[](https://gitlab.com/rigogsilva/polisher/commits/main)
[](https://gitlab.com/rigogsilva/polisher/commits/main)
[](http://mypy-lang.org/)
[](https://pypi.org/project/polisher/)
[[_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:
```python
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()
```

### 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.
```python
import polisher
polisher.remove_grids(figure=fig)
polisher.remove_background(figure=fig)
fig.show()
```

#### 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.
```python
polisher.send_to_background(fig)
fig.show()
```

Notice the difference between the default bar graph and our new version.
| Default Bar Plot | No Distractions Bar Plot |
|-----------------------------------------------|:-----------------------------------------------------------------|
|  |  |
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:
```shell
poetry run task publish
```
Build the pip library package to deploy to pip:
```shell script
python3 setup.py sdist bdist_wheel
```
Publish to pip. You can follow steps [here](https://docs.gitlab.com/ee/user/packages/pypi_repository/)
Note that you will need to install twine and register your pypi. Usually in the file
`~/.pypirc`
```shell script
python3 -m twine upload --repository pypi dist/*
```
## Installation
```shell script
pip install polisher
```
## Testing
To test this project run:
```shell script
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](http://www.unnotebook.com/) to plot the examples.
1. Build and push `notebook` image:
```bash
docker build . -t polisher
```
2. Run notebook
```shell script
docker-compose up notebook
```
or
```bash
docker run --rm -it \
-v /Users/rigo/Documents/Projects/notebooks/stock-predictions:/notebooks \
-p 8899:8899 unclutterer
```
3. Open http://localhost:8899/ and open the notebook you want to run.
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/rigogsilva/polisher",
"name": "polisher",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Rodrigo da Silva",
"author_email": "dasil021@umn.edu",
"download_url": "https://files.pythonhosted.org/packages/9d/6e/c8d4533ac1f0519e6cfc70623ee44b3bfc1c3781aed6503f2f02e5ad86d7/polisher-2.0.4.tar.gz",
"platform": null,
"description": "# polisher\n\n[](https://pypi.org/project/polisher/)\n[](https://gitlab.com/rigogsilva/polisher/commits/main)\n[](https://gitlab.com/rigogsilva/polisher/commits/main)\n[](http://mypy-lang.org/)\n[](https://pypi.org/project/polisher/)\n\n[[_TOC_]]\n\nGraph polisher is a library that helps you clean your plotly figures. \nThis library was inspired by the book \"Storytelling with Data by Cole\nNussbaumer Knaflic (https://www.kobo.com/us/en/ebook/storytelling-with-data).\n\n## Usage\n\nTo start our graph polishing, we will create a basic bar graph:\n\n```python\nimport pandas as pd\nimport plotly.express as px\n\nreport_data = [\n {'name': 'Time Sheets', 'exported': 394},\n {'name': 'Schedules', 'exported': 171},\n {'name': 'overtime', 'exported': 457},\n {'name': 'Time-off', 'exported': 93},\n {'name': 'Shift Requests', 'exported': 30},\n]\ndf = pd.DataFrame(report_data)\n\nfig = px.bar(df, title='Exported Reports', x='name', y='exported')\n\nfig.show()\n```\n\n\n\n### Cleaning the Graph\n\nNext, we will remove all the unnecessary information from the graph. By removing\nunnecessary things from the graph, we will then be able to focus on important\ninformation that will help us drive the user to where we want them to focus on. \n\nTo remove all that default unnecessary information with polisher\ndo the following:\n\n#### Remove grid lines and background\n\nGrid lines usually compete with the information being shown. If you really think\nthat you should include them, make them thin and grey so it doesn't call\nattention.\n\n```python\nimport polisher\n\npolisher.remove_grids(figure=fig)\npolisher.remove_background(figure=fig)\n\nfig.show()\n```\n\n\n\n#### Send to background\n\nThe dark colors (black text, bold text) of the graph also calls for attention.\nWe can easily make them less attention grabbing by sending them to\nthe background. Sending them to the background will set the text color to a more neutral\ncolor like grey. \n\n```python\npolisher.send_to_background(fig)\n\nfig.show()\n```\n\n\n\nNotice the difference between the default bar graph and our new version. \n\n| Default Bar Plot | No Distractions Bar Plot |\n|-----------------------------------------------|:-----------------------------------------------------------------|\n|  |  |\n\nNow you have a graph that you can easily add intentional attention grabbing\ninformation so that your user is guided through the information you are trying\nto present.\n\n## Deploying pip library\n\nShortcut for commands below: \n\n```shell\npoetry run task publish\n```\n\nBuild the pip library package to deploy to pip:\n\n```shell script\npython3 setup.py sdist bdist_wheel\n```\n\nPublish to pip. You can follow steps [here](https://docs.gitlab.com/ee/user/packages/pypi_repository/) \n\nNote that you will need to install twine and register your pypi. Usually in the file\n`~/.pypirc`\n\n```shell script\npython3 -m twine upload --repository pypi dist/*\n```\n\n## Installation\n\n```shell script\npip install polisher\n```\n\n## Testing\n\nTo test this project run:\n\n```shell script\npoetry run task test\n```\n\n## Notebook Example (with unnotebook)\n\nPrerequisite: https://www.docker.com/\n\nYou can use this to see how the library modifies the plots. We are using \n[unnotebook](http://www.unnotebook.com/) to plot the examples. \n\n1. Build and push `notebook` image:\n\n```bash\ndocker build . -t polisher\n```\n\n2. Run notebook\n\n```shell script\ndocker-compose up notebook\n```\n\nor \n\n```bash\ndocker run --rm -it \\\n -v /Users/rigo/Documents/Projects/notebooks/stock-predictions:/notebooks \\\n -p 8899:8899 unclutterer\n```\n\n3. Open http://localhost:8899/ and open the notebook you want to run.\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "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).",
"version": "2.0.4",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "a54023e77faae78033b6650dda3b43ff",
"sha256": "561bccfda1b3cf85024e97b28793eff004ad18b0c6073fc74fa75b34fd45fbf8"
},
"downloads": -1,
"filename": "polisher-2.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a54023e77faae78033b6650dda3b43ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7235,
"upload_time": "2022-12-20T20:14:27",
"upload_time_iso_8601": "2022-12-20T20:14:27.042539Z",
"url": "https://files.pythonhosted.org/packages/8c/a6/4a30d57206f0930e0d325cffcbf48c1695f62701f23b049bf3b8eee241d7/polisher-2.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "686d891b37155ebe5a8f5d1082a80e06",
"sha256": "68964b1dc1f0efc63ae49a3e70ae3b8310d394d84e71c50a94c7980ae8a3f076"
},
"downloads": -1,
"filename": "polisher-2.0.4.tar.gz",
"has_sig": false,
"md5_digest": "686d891b37155ebe5a8f5d1082a80e06",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 8078,
"upload_time": "2022-12-20T20:14:28",
"upload_time_iso_8601": "2022-12-20T20:14:28.578406Z",
"url": "https://files.pythonhosted.org/packages/9d/6e/c8d4533ac1f0519e6cfc70623ee44b3bfc1c3781aed6503f2f02e5ad86d7/polisher-2.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-20 20:14:28",
"github": false,
"gitlab": true,
"bitbucket": false,
"gitlab_user": "rigogsilva",
"gitlab_project": "polisher",
"lcname": "polisher"
}