distinctipy


Namedistinctipy JSON
Version 1.3.4 PyPI version JSON
download
home_page
SummaryA lightweight package for generating visually distinct colours.
upload_time2024-01-10 21:32:24
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2019 The Alan Turing Institute 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.
keywords color colour palette colormap colorblind colourblind
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![distinctipy logo](https://raw.githubusercontent.com/alan-turing-institute/distinctipy/main/distinctipy_logo.png)

[![tests](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonapp.yml/badge.svg)](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonapp.yml)
[![build](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonpublish.yml/badge.svg)](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonpublish.yml)
[![codecov](https://codecov.io/gh/alan-turing-institute/distinctipy/branch/main/graph/badge.svg)](https://codecov.io/gh/alan-turing-institute/distinctipy)
[![DOI](https://zenodo.org/badge/188444660.svg)](https://zenodo.org/badge/latestdoi/188444660)
[![Documentation Status](https://readthedocs.org/projects/distinctipy/badge/?version=latest)](https://distinctipy.readthedocs.io/en/latest/?badge=latest)

_distinctipy_ is a lightweight python package providing functions to generate
colours that are visually distinct from one another.

Commonly available qualitative colormaps provided by the likes of matplotlib
generally have no more than 20 colours, but for some applications it is useful
to have many more colours that are clearly different from one another.
_distinctipy_ can generate lists of colours of any length, with each new colour
added to the list being as visually distinct from the pre-existing colours in
the list as possible.

## Installation

_distinctipy_ is designed for Python 3 and can be installed with pip by running:

```shell
python -m pip install distinctipy
```

Alternatively clone the repo and install it locally:

```shell
git clone https://github.com/alan-turing-institute/distinctipy.git
cd distinctipy
python -m pip install .
```

### Optional Dependencies

Starting in version 1.2.1 `distinctipy` no longer bundles `matplotlib`, `pandas` or dev dependencies in the default installation. If you wish to view
colours (e.g. with `distinctipy.color_swatch`) or examples you will need `matplotlib` and `pandas` installed. To do this, either install `distinctipy`
with the optional flag:

```bash
python -m pip install distinctipy[extras]
```

⚠️ Warning ⚠️ Previous versions of distinctipy (before 1.3) used `[optional]` instead of `[extras]`.

Or install them separately:

```bash
python -m pip install matplotlib pandas
```

For developers, to install the stack needed to run tests, generate docs etc. use:

```bash
python -m pip install distinctipy[extras,tests,docs]
```

## Usage and Examples

_distinctipy_ can:

- Generate N visually distinct colours: `distinctipy.get_colors(N)`
- Generate colours that are distinct from an existing list of colours: `distinctipy.get_colors(N, existing_colors)`
- Generate pastel colours: `distinctipy.get_colors(N, pastel_factor=0.7)`
- Select black or white as the best font colour for any background colour: `distinctipy.get_text_color(background_color)`
- Convert lists of colours into matplotlib colormaps: `distinctipy.get_colormap(colors)`
- Invert colours: `distinctipy.invert_colors(colors)`
- Nicely display generated colours: `distinctipy.color_swatch(colors)`
- Compare distinctipy colours to other common colormaps: `examples.compare_clusters()` and `examples.compare_colors()`
- Simulate how colours look for someone with colourblindness: `colorblind.simulate_colors(colors, colorblind_type='Deuteranomaly')`
- Attempt to generate colours as distinct as possible for someone with colourblindness `distinctipy.get_colors(N, existing_colors, colorblind_type="Deuteranomaly")`

For example, to create and then display N = 36 visually distinct colours:

```python
import distinctipy

# number of colours to generate
N = 36

# generate N visually distinct colours
colors = distinctipy.get_colors(N)

# display the colours
distinctipy.color_swatch(colors)
```

More detailed usage and example output can be found in the notebook **[examples.ipynb](https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb)** and **[examples gallery](https://github.com/alan-turing-institute/distinctipy/tree/main/examples)**.

## References

_distinctipy_ was heavily influenced and inspired by several web sources and
stack overflow answers. In particular:

- **Random generation of distinct colours:** [Andrew Dewes on GitHub](https://gist.github.com/adewes/5884820)
- **Colour distance metric:** [Thiadmer Riemersma at CompuPhase](https://www.compuphase.com/cmetric.htm)
- **Best text colour for background:** [Mark Ransom on Stack Overflow](https://stackoverflow.com/a/3943023)
- **Colourblindness Filters:** [Matthew Wickline and the Human-Computer Interaction Resource Network](http://web.archive.org/web/20090318054431/http://www.nofunc.com/Color_Blindness_Library) (web archive)

## Citing distinctipy

If you would like to cite distinctipy, please refer to the upload of the package on Zenodo: https://doi.org/10.5281/zenodo.3985191

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "distinctipy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "color,colour,palette,colormap,colorblind,colourblind",
    "author": "",
    "author_email": "Jack Roberts <jroberts@turing.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/8c/3c/e0b90a5bc396e2abaf207d9a41ea8aeab1f41760425262474903bade6a7b/distinctipy-1.3.4.tar.gz",
    "platform": null,
    "description": "![distinctipy logo](https://raw.githubusercontent.com/alan-turing-institute/distinctipy/main/distinctipy_logo.png)\n\n[![tests](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonapp.yml/badge.svg)](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonapp.yml)\n[![build](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonpublish.yml/badge.svg)](https://github.com/alan-turing-institute/distinctipy/actions/workflows/pythonpublish.yml)\n[![codecov](https://codecov.io/gh/alan-turing-institute/distinctipy/branch/main/graph/badge.svg)](https://codecov.io/gh/alan-turing-institute/distinctipy)\n[![DOI](https://zenodo.org/badge/188444660.svg)](https://zenodo.org/badge/latestdoi/188444660)\n[![Documentation Status](https://readthedocs.org/projects/distinctipy/badge/?version=latest)](https://distinctipy.readthedocs.io/en/latest/?badge=latest)\n\n_distinctipy_ is a lightweight python package providing functions to generate\ncolours that are visually distinct from one another.\n\nCommonly available qualitative colormaps provided by the likes of matplotlib\ngenerally have no more than 20 colours, but for some applications it is useful\nto have many more colours that are clearly different from one another.\n_distinctipy_ can generate lists of colours of any length, with each new colour\nadded to the list being as visually distinct from the pre-existing colours in\nthe list as possible.\n\n## Installation\n\n_distinctipy_ is designed for Python 3 and can be installed with pip by running:\n\n```shell\npython -m pip install distinctipy\n```\n\nAlternatively clone the repo and install it locally:\n\n```shell\ngit clone https://github.com/alan-turing-institute/distinctipy.git\ncd distinctipy\npython -m pip install .\n```\n\n### Optional Dependencies\n\nStarting in version 1.2.1 `distinctipy` no longer bundles `matplotlib`, `pandas` or dev dependencies in the default installation. If you wish to view\ncolours (e.g. with `distinctipy.color_swatch`) or examples you will need `matplotlib` and `pandas` installed. To do this, either install `distinctipy`\nwith the optional flag:\n\n```bash\npython -m pip install distinctipy[extras]\n```\n\n\u26a0\ufe0f Warning \u26a0\ufe0f Previous versions of distinctipy (before 1.3) used `[optional]` instead of `[extras]`.\n\nOr install them separately:\n\n```bash\npython -m pip install matplotlib pandas\n```\n\nFor developers, to install the stack needed to run tests, generate docs etc. use:\n\n```bash\npython -m pip install distinctipy[extras,tests,docs]\n```\n\n## Usage and Examples\n\n_distinctipy_ can:\n\n- Generate N visually distinct colours: `distinctipy.get_colors(N)`\n- Generate colours that are distinct from an existing list of colours: `distinctipy.get_colors(N, existing_colors)`\n- Generate pastel colours: `distinctipy.get_colors(N, pastel_factor=0.7)`\n- Select black or white as the best font colour for any background colour: `distinctipy.get_text_color(background_color)`\n- Convert lists of colours into matplotlib colormaps: `distinctipy.get_colormap(colors)`\n- Invert colours: `distinctipy.invert_colors(colors)`\n- Nicely display generated colours: `distinctipy.color_swatch(colors)`\n- Compare distinctipy colours to other common colormaps: `examples.compare_clusters()` and `examples.compare_colors()`\n- Simulate how colours look for someone with colourblindness: `colorblind.simulate_colors(colors, colorblind_type='Deuteranomaly')`\n- Attempt to generate colours as distinct as possible for someone with colourblindness `distinctipy.get_colors(N, existing_colors, colorblind_type=\"Deuteranomaly\")`\n\nFor example, to create and then display N = 36 visually distinct colours:\n\n```python\nimport distinctipy\n\n# number of colours to generate\nN = 36\n\n# generate N visually distinct colours\ncolors = distinctipy.get_colors(N)\n\n# display the colours\ndistinctipy.color_swatch(colors)\n```\n\nMore detailed usage and example output can be found in the notebook **[examples.ipynb](https://github.com/alan-turing-institute/distinctipy/blob/main/examples.ipynb)** and **[examples gallery](https://github.com/alan-turing-institute/distinctipy/tree/main/examples)**.\n\n## References\n\n_distinctipy_ was heavily influenced and inspired by several web sources and\nstack overflow answers. In particular:\n\n- **Random generation of distinct colours:** [Andrew Dewes on GitHub](https://gist.github.com/adewes/5884820)\n- **Colour distance metric:** [Thiadmer Riemersma at CompuPhase](https://www.compuphase.com/cmetric.htm)\n- **Best text colour for background:** [Mark Ransom on Stack Overflow](https://stackoverflow.com/a/3943023)\n- **Colourblindness Filters:** [Matthew Wickline and the Human-Computer Interaction Resource Network](http://web.archive.org/web/20090318054431/http://www.nofunc.com/Color_Blindness_Library) (web archive)\n\n## Citing distinctipy\n\nIf you would like to cite distinctipy, please refer to the upload of the package on Zenodo: https://doi.org/10.5281/zenodo.3985191\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2019 The Alan Turing Institute  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:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  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. ",
    "summary": "A lightweight package for generating visually distinct colours.",
    "version": "1.3.4",
    "project_urls": {
        "Documentation": "https://distinctipy.readthedocs.io/",
        "Homepage": "https://github.com/alan-turing-institute/distinctipy"
    },
    "split_keywords": [
        "color",
        "colour",
        "palette",
        "colormap",
        "colorblind",
        "colourblind"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a75fa882538bdb0c8fc4459f1595a761591b827691936d57c08c492676f19bc",
                "md5": "7c9280d4de2cea7d6ab1d0440cb59ede",
                "sha256": "2bf57d9d20dbc5c2fd462298573cc963c037f493d04ec61e94cb8d0bf5023c74"
            },
            "downloads": -1,
            "filename": "distinctipy-1.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7c9280d4de2cea7d6ab1d0440cb59ede",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 26743,
            "upload_time": "2024-01-10T21:32:22",
            "upload_time_iso_8601": "2024-01-10T21:32:22.351099Z",
            "url": "https://files.pythonhosted.org/packages/0a/75/fa882538bdb0c8fc4459f1595a761591b827691936d57c08c492676f19bc/distinctipy-1.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c3ce0b90a5bc396e2abaf207d9a41ea8aeab1f41760425262474903bade6a7b",
                "md5": "f5bf5cd679cfb88e510b233774bce2ee",
                "sha256": "fed97afff1afb73ecaa87c85461021f0ba89fae63067c0125b9673526510aac4"
            },
            "downloads": -1,
            "filename": "distinctipy-1.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f5bf5cd679cfb88e510b233774bce2ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 29711,
            "upload_time": "2024-01-10T21:32:24",
            "upload_time_iso_8601": "2024-01-10T21:32:24.032990Z",
            "url": "https://files.pythonhosted.org/packages/8c/3c/e0b90a5bc396e2abaf207d9a41ea8aeab1f41760425262474903bade6a7b/distinctipy-1.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 21:32:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alan-turing-institute",
    "github_project": "distinctipy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "distinctipy"
}
        
Elapsed time: 0.17042s