Name | cmap JSON |
Version |
0.4.0
JSON |
| download |
home_page | None |
Summary | Scientific colormaps for python, without dependencies |
upload_time | 2024-11-01 20:28:19 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | BSD 3-Clause License |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# cmap
[![License](https://img.shields.io/pypi/l/cmap.svg?color=green)](https://github.com/pyapp-kit/cmap/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/cmap.svg?color=green)](https://pypi.org/project/cmap)
![Conda](https://img.shields.io/conda/v/conda-forge/cmap)
[![Python Version](https://img.shields.io/pypi/pyversions/cmap.svg?color=green)](https://python.org)
[![CI](https://github.com/pyapp-kit/cmap/actions/workflows/ci.yml/badge.svg)](https://github.com/pyapp-kit/cmap/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/pyapp-kit/cmap/branch/main/graph/badge.svg)](https://codecov.io/gh/pyapp-kit/cmap)
[![Documentation Status](https://readthedocs.org/projects/cmap-docs/badge/?version=latest)](https://cmap-docs.readthedocs.io/en/latest/?badge=latest)
Scientific colormaps for python, with no dependencies beyond numpy.
With `cmap`, you can use any of the colormaps from
[matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html),
[cmocean](https://matplotlib.org/cmocean/),
[colorbrewer](https://colorbrewer2.org/),
[crameri](https://www.fabiocrameri.ch/colourmaps/),
[seaborn](https://seaborn.pydata.org/tutorial/color_palettes.html), and a host
of other collections in your python code, without having to install matplotlib
or any other dependencies beyond numpy.
:book: [See the complete
catalog](https://cmap-docs.readthedocs.io/en/latest/catalog/)
There are a number of python libraries that provide or require colormaps or
basic color support, but they all either depend on matplotlib, provide a
specialized set of colormaps intended to extend those provided by matplotlib, or
roll their own colormap solution that vendors/duplicates other libraries.
`cmap` is a lightweight library that provides a large collection of colormaps
with no dependencies beyond numpy. It provides exports to a number of known
third-party colormap objects, allowing it to be used across a wide range of
python visualization libraries. The intention is to provide a library that can
be used by any python library that needs colormaps, without forcing the user to
install matplotlib (while still being compatible with matplotlib and other
libraries that use matplotlib colormaps).
`cmap` is strictly typed and fully tested, with a focus on good developer
experience.
## Install
```
pip install cmap
```
```
conda install -c conda-forge cmap
```
## Usage
See [Documentation](https://cmap-docs.readthedocs.io/) for full details.
### [`cmap.Color`](https://cmap-docs.readthedocs.io/en/latest/colors/)
The `cmap.Color` object is a simple wrapper around a tuple of RGBA scalars, with
a few convenience methods for converting to other color objects.
```python
from cmap import Color
red = Color("red") # or a variety of other "color like" inputs
```
### [`cmap.Colormap`](https://cmap-docs.readthedocs.io/en/latest/colormaps/)
The `cmap.Colormap` object is a callable that can map a scalar value (or numpy
array of values) to an RGBA color (or a numpy array of RGBA colors). API is
intended to mimic the behavior of a
[`matplotlib.colors.Colormap`](https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.Colormap.html#matplotlib.colors.Colormap)
object (without requiring matplotlib)
```python
In [1]: import cmap
# or a variety of other "colormap like" inputs
In [2]: cmap1 = cmap.Colormap(["red", "green", "blue"])
In [3]: cmap1(np.linspace(0,1,5))
Out[3]:
array([[1. , 0. , 0. , 1. ],
[0.50393701, 0.24900417, 0. , 1. ],
[0. , 0.50196078, 0. , 1. ],
[0. , 0.24900417, 0.50393701, 1. ],
[0. , 0. , 1. , 1. ]])
```
Note that the input array must be normalized from 0-1, so if you're applying a colormap
to an integer array (like an image) you must apply any contrast limits and rescale to
0-1 before passing it to a `Colormap`.
## Third Party Library Support
The `cmap.Colormap` object has convenience methods that export it to a number of known
third-party colormap objects, including:
- [matplotlib](https://matplotlib.org/)
- [napari](https://napari.org/)
- [vispy](https://vispy.org/)
- [pygfx](https://pygfx.readthedocs.io/en/latest/) (& [fastplotlib](https://github.com/fastplotlib/fastplotlib))
- [plotly](https://plotly.com/python/)
- [bokeh](https://docs.bokeh.org/en/latest/)
- [altair](https://altair-viz.github.io/)
- [pyqtgraph](https://www.pyqtgraph.org/)
See [documentation](https://cmap-docs.readthedocs.io/en/latest/colormaps/#usage-with-external-visualization-libraries)
for details.
If you would like to see support added for a particular library, please open an issue or PR.
## Alternatives
Other libraries providing colormaps:
- [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)
- [seaborn](https://seaborn.pydata.org/tutorial/color_palettes.html) (subclasses matplotlib)
- [proplot](https://proplot.readthedocs.io/en/latest/colormaps.html) (subclasses matplotlib)
- [palettable](https://jiffyclub.github.io/palettable/) (mostly data, import doesn't depend on matplotlib, but usage largely does)
- [cmocean](https://matplotlib.org/cmocean/) (mostly data, outputs matplotlib colormaps)
- [colorcet](https://colorcet.holoviz.org/) (mostly data, usage requires either matplotlib or bokeh)
- [cmasher](https://cmasher.readthedocs.io/) (requires matplotlib)
- [cmyt](https://github.com/yt-project/cmyt) (requires matplotlib)
- [cmcrameri](https://github.com/callumrollo/cmcrameri) (requires matplotlib, wraps <https://www.fabiocrameri.ch/colourmaps/>)
- [distinctipy](https://github.com/alan-turing-institute/distinctipy) (generates distinct color sets, only requires numpy)
- [Farrow & Ball Matplotlib](https://github.com/vork/farrowandball) (requires matplotlib)
- [mplcyberpunk](https://github.com/dhaitz/mplcyberpunk) (requires matplotlib)
## References and Further reading
- [Choosing Colormaps in Matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)
- [A Better Default Colormap for Matplotlib | SciPy 2015 | Nathaniel Smith and SteĢfan van der Walt](https://www.youtube.com/watch?v=xAoljeRJ3lU)
- blog post for above video: <https://bids.github.io/colormap/>
- [Origins of Colormaps, Cleve Moler, February 2, 2015](https://blogs.mathworks.com/cleve/2015/02/02/origins-of-colormaps/)
- [Documenting the matplotlib colormaps, @endolith](https://gist.github.com/endolith/2719900)
- [Color Map Advice for Scientific Visualization](https://www.kennethmoreland.com/color-advice/)
- <https://colorcet.com/>, Peter Kovesi
- [Kovesi: Good Colour Maps: How to Design Them.](https://arxiv.org/abs/1509.03700)
- <https://www.fabiocrameri.ch/colourmaps/>
Raw data
{
"_id": null,
"home_page": null,
"name": "cmap",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Talley Lambert <talley.lambert@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d8/50/d1286f03f8afd169800e79310c89014ba4f281b008c1f71cb62d1d909204/cmap-0.4.0.tar.gz",
"platform": null,
"description": "# cmap\n\n[![License](https://img.shields.io/pypi/l/cmap.svg?color=green)](https://github.com/pyapp-kit/cmap/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/cmap.svg?color=green)](https://pypi.org/project/cmap)\n![Conda](https://img.shields.io/conda/v/conda-forge/cmap)\n[![Python Version](https://img.shields.io/pypi/pyversions/cmap.svg?color=green)](https://python.org)\n[![CI](https://github.com/pyapp-kit/cmap/actions/workflows/ci.yml/badge.svg)](https://github.com/pyapp-kit/cmap/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/pyapp-kit/cmap/branch/main/graph/badge.svg)](https://codecov.io/gh/pyapp-kit/cmap)\n[![Documentation Status](https://readthedocs.org/projects/cmap-docs/badge/?version=latest)](https://cmap-docs.readthedocs.io/en/latest/?badge=latest)\n\nScientific colormaps for python, with no dependencies beyond numpy.\n\nWith `cmap`, you can use any of the colormaps from\n[matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html),\n[cmocean](https://matplotlib.org/cmocean/),\n[colorbrewer](https://colorbrewer2.org/),\n[crameri](https://www.fabiocrameri.ch/colourmaps/),\n[seaborn](https://seaborn.pydata.org/tutorial/color_palettes.html), and a host\nof other collections in your python code, without having to install matplotlib\nor any other dependencies beyond numpy.\n\n:book: [See the complete\ncatalog](https://cmap-docs.readthedocs.io/en/latest/catalog/)\n\nThere are a number of python libraries that provide or require colormaps or\nbasic color support, but they all either depend on matplotlib, provide a\nspecialized set of colormaps intended to extend those provided by matplotlib, or\nroll their own colormap solution that vendors/duplicates other libraries.\n\n`cmap` is a lightweight library that provides a large collection of colormaps\nwith no dependencies beyond numpy. It provides exports to a number of known\nthird-party colormap objects, allowing it to be used across a wide range of\npython visualization libraries. The intention is to provide a library that can\nbe used by any python library that needs colormaps, without forcing the user to\ninstall matplotlib (while still being compatible with matplotlib and other\nlibraries that use matplotlib colormaps).\n\n`cmap` is strictly typed and fully tested, with a focus on good developer\nexperience.\n\n## Install\n\n```\npip install cmap\n```\n\n```\nconda install -c conda-forge cmap\n```\n\n## Usage\n\nSee [Documentation](https://cmap-docs.readthedocs.io/) for full details.\n\n### [`cmap.Color`](https://cmap-docs.readthedocs.io/en/latest/colors/)\n\nThe `cmap.Color` object is a simple wrapper around a tuple of RGBA scalars, with\na few convenience methods for converting to other color objects.\n\n```python\nfrom cmap import Color\n\nred = Color(\"red\") # or a variety of other \"color like\" inputs\n```\n\n### [`cmap.Colormap`](https://cmap-docs.readthedocs.io/en/latest/colormaps/)\n\nThe `cmap.Colormap` object is a callable that can map a scalar value (or numpy\narray of values) to an RGBA color (or a numpy array of RGBA colors). API is\nintended to mimic the behavior of a\n[`matplotlib.colors.Colormap`](https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.Colormap.html#matplotlib.colors.Colormap)\nobject (without requiring matplotlib)\n\n```python\nIn [1]: import cmap\n\n# or a variety of other \"colormap like\" inputs\nIn [2]: cmap1 = cmap.Colormap([\"red\", \"green\", \"blue\"])\n\nIn [3]: cmap1(np.linspace(0,1,5))\nOut[3]:\narray([[1. , 0. , 0. , 1. ],\n [0.50393701, 0.24900417, 0. , 1. ],\n [0. , 0.50196078, 0. , 1. ],\n [0. , 0.24900417, 0.50393701, 1. ],\n [0. , 0. , 1. , 1. ]])\n```\n\nNote that the input array must be normalized from 0-1, so if you're applying a colormap\nto an integer array (like an image) you must apply any contrast limits and rescale to\n0-1 before passing it to a `Colormap`.\n\n## Third Party Library Support\n\nThe `cmap.Colormap` object has convenience methods that export it to a number of known\nthird-party colormap objects, including:\n\n- [matplotlib](https://matplotlib.org/)\n- [napari](https://napari.org/)\n- [vispy](https://vispy.org/)\n- [pygfx](https://pygfx.readthedocs.io/en/latest/) (& [fastplotlib](https://github.com/fastplotlib/fastplotlib))\n- [plotly](https://plotly.com/python/)\n- [bokeh](https://docs.bokeh.org/en/latest/)\n- [altair](https://altair-viz.github.io/)\n- [pyqtgraph](https://www.pyqtgraph.org/)\n\nSee [documentation](https://cmap-docs.readthedocs.io/en/latest/colormaps/#usage-with-external-visualization-libraries)\nfor details.\n\nIf you would like to see support added for a particular library, please open an issue or PR.\n\n## Alternatives\n\nOther libraries providing colormaps:\n\n- [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)\n- [seaborn](https://seaborn.pydata.org/tutorial/color_palettes.html) (subclasses matplotlib)\n- [proplot](https://proplot.readthedocs.io/en/latest/colormaps.html) (subclasses matplotlib)\n- [palettable](https://jiffyclub.github.io/palettable/) (mostly data, import doesn't depend on matplotlib, but usage largely does)\n- [cmocean](https://matplotlib.org/cmocean/) (mostly data, outputs matplotlib colormaps)\n- [colorcet](https://colorcet.holoviz.org/) (mostly data, usage requires either matplotlib or bokeh)\n- [cmasher](https://cmasher.readthedocs.io/) (requires matplotlib)\n- [cmyt](https://github.com/yt-project/cmyt) (requires matplotlib)\n- [cmcrameri](https://github.com/callumrollo/cmcrameri) (requires matplotlib, wraps <https://www.fabiocrameri.ch/colourmaps/>)\n- [distinctipy](https://github.com/alan-turing-institute/distinctipy) (generates distinct color sets, only requires numpy)\n- [Farrow & Ball Matplotlib](https://github.com/vork/farrowandball) (requires matplotlib)\n- [mplcyberpunk](https://github.com/dhaitz/mplcyberpunk) (requires matplotlib)\n\n## References and Further reading\n\n- [Choosing Colormaps in Matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)\n- [A Better Default Colormap for Matplotlib | SciPy 2015 | Nathaniel Smith and Ste\u0301fan van der Walt](https://www.youtube.com/watch?v=xAoljeRJ3lU)\n- blog post for above video: <https://bids.github.io/colormap/>\n- [Origins of Colormaps, Cleve Moler, February 2, 2015](https://blogs.mathworks.com/cleve/2015/02/02/origins-of-colormaps/)\n- [Documenting the matplotlib colormaps, @endolith](https://gist.github.com/endolith/2719900)\n- [Color Map Advice for Scientific Visualization](https://www.kennethmoreland.com/color-advice/)\n- <https://colorcet.com/>, Peter Kovesi\n- [Kovesi: Good Colour Maps: How to Design Them.](https://arxiv.org/abs/1509.03700)\n- <https://www.fabiocrameri.ch/colourmaps/>\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "Scientific colormaps for python, without dependencies",
"version": "0.4.0",
"project_urls": {
"Bug Tracker": "https://github.com/pyapp-kit/cmap/issues",
"Documentation": "https://cmap-docs.rtfd.io/",
"Homepage": "https://github.com/pyapp-kit/cmap",
"Repository": "https://github.com/pyapp-kit/cmap"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be66dafbc534cec8b4a16bd2d19e37a83ccffb7c68cc73bc684f2dd3777bed5f",
"md5": "30517343825b61a0e3b5d73e32abdeea",
"sha256": "e54d87aa13181ad6bd2372d2930b8b0851776619077d9989fe42e3255f938f17"
},
"downloads": -1,
"filename": "cmap-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "30517343825b61a0e3b5d73e32abdeea",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 937840,
"upload_time": "2024-11-01T20:28:17",
"upload_time_iso_8601": "2024-11-01T20:28:17.583872Z",
"url": "https://files.pythonhosted.org/packages/be/66/dafbc534cec8b4a16bd2d19e37a83ccffb7c68cc73bc684f2dd3777bed5f/cmap-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d850d1286f03f8afd169800e79310c89014ba4f281b008c1f71cb62d1d909204",
"md5": "245ffd1c7d6448a11ece2c11503f761e",
"sha256": "6d93e8d01502f507ca8a83b76156d52b26f737f488a89154498429cad57ac1fb"
},
"downloads": -1,
"filename": "cmap-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "245ffd1c7d6448a11ece2c11503f761e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 891824,
"upload_time": "2024-11-01T20:28:19",
"upload_time_iso_8601": "2024-11-01T20:28:19.472301Z",
"url": "https://files.pythonhosted.org/packages/d8/50/d1286f03f8afd169800e79310c89014ba4f281b008c1f71cb62d1d909204/cmap-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-01 20:28:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pyapp-kit",
"github_project": "cmap",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cmap"
}