{"id":19921500,"url":"https://github.com/pyapp-kit/cmap","last_synced_at":"2025-05-16T10:07:16.143Z","repository":{"id":65654915,"uuid":"583999033","full_name":"pyapp-kit/cmap","owner":"pyapp-kit","description":"Scientific colormaps for python, with only numpy dependency","archived":false,"fork":false,"pushed_at":"2025-05-05T20:54:12.000Z","size":29379,"stargazers_count":116,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-14T07:12:29.032Z","etag":null,"topics":["colormaps","python","visualization"],"latest_commit_sha":null,"homepage":"https://cmap-docs.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyapp-kit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE/LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-31T20:55:32.000Z","updated_at":"2025-05-08T07:43:11.000Z","dependencies_parsed_at":"2023-11-27T19:29:40.686Z","dependency_job_id":"5e9678da-51e4-409a-8ea4-d219b76c4dd1","html_url":"https://github.com/pyapp-kit/cmap","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fcmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fcmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fcmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyapp-kit%2Fcmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyapp-kit","download_url":"https://codeload.github.com/pyapp-kit/cmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colormaps","python","visualization"],"created_at":"2024-11-12T22:07:46.221Z","updated_at":"2025-05-16T10:07:11.133Z","avatar_url":"https://github.com/pyapp-kit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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/) (\u0026 [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- [earthengine-api](https://developers.google.com/earth-engine/guides/quickstart_python)\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 \u003chttps://www.fabiocrameri.ch/colourmaps/\u003e)\n- [distinctipy](https://github.com/alan-turing-institute/distinctipy)  (generates distinct color sets, only requires numpy)\n- [Farrow \u0026 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́fan van der Walt](https://www.youtube.com/watch?v=xAoljeRJ3lU)\n- blog post for above video: \u003chttps://bids.github.io/colormap/\u003e\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- \u003chttps://colorcet.com/\u003e, Peter Kovesi\n- [Kovesi: Good Colour Maps: How to Design Them.](https://arxiv.org/abs/1509.03700)\n- \u003chttps://www.fabiocrameri.ch/colourmaps/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fcmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyapp-kit%2Fcmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyapp-kit%2Fcmap/lists"}