{"id":17737756,"url":"https://github.com/tdegeus/cppcolormap","last_synced_at":"2025-05-08T20:37:28.881Z","repository":{"id":20693269,"uuid":"85969567","full_name":"tdegeus/cppcolormap","owner":"tdegeus","description":"Library with colormaps for C++","archived":false,"fork":false,"pushed_at":"2023-10-12T09:58:34.000Z","size":678,"stargazers_count":23,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-16T06:53:11.591Z","etag":null,"topics":["colorbrewer","colormap","cpp","cppmat","python","python3"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdegeus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2017-03-23T16:02:02.000Z","updated_at":"2024-04-06T10:12:30.000Z","dependencies_parsed_at":"2023-10-12T18:11:44.587Z","dependency_job_id":null,"html_url":"https://github.com/tdegeus/cppcolormap","commit_stats":{"total_commits":93,"total_committers":3,"mean_commits":31.0,"dds":"0.18279569892473113","last_synced_commit":"2fe9454fe971785000d7521ee32b49bbba950c39"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdegeus%2Fcppcolormap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdegeus%2Fcppcolormap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdegeus%2Fcppcolormap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdegeus%2Fcppcolormap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdegeus","download_url":"https://codeload.github.com/tdegeus/cppcolormap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253146570,"owners_count":21861426,"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":["colorbrewer","colormap","cpp","cppmat","python","python3"],"created_at":"2024-10-26T01:42:38.188Z","updated_at":"2025-05-08T20:37:28.727Z","avatar_url":"https://github.com/tdegeus.png","language":"C++","readme":"[![CI](https://github.com/tdegeus/cppcolormap/workflows/CI/badge.svg)](https://github.com/tdegeus/cppcolormap/actions)\n[![Doxygen -\u003e gh-pages](https://github.com/tdegeus/cppcolormap/workflows/gh-pages/badge.svg)](https://tdegeus.github.io/cppcolormap)\n[![Documentation Status](https://readthedocs.org/projects/cppcolormap/badge/?version=latest)](https://readthedocs.org/projects/cppcolormap/badge/?version=latest)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/cppcolormap.svg)](https://anaconda.org/conda-forge/cppcolormap)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/python-cppcolormap.svg)](https://anaconda.org/conda-forge/python-cppcolormap)\n\nDocumentation: [cppcolormap.readthedocs.org](https://cppcolormap.readthedocs.org)\n\nDoxygen documentation: [tdegeus.github.io/cppcolormap](https://tdegeus.github.io/cppcolormap)\n\n# cppcolormap\n\nC++ and Python library specifying colormaps.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/Sequential.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/Diverging.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/matplotlib.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/monocolor.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/monocolor_dvips_1.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/monocolor_dvips_2.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/Qualitative.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./examples/overview/Colorcycles.png\"\u003e\n\u003c/p\u003e\n\n# Contents\n\n# Disclaimer\n\nThis library is free to use under the [GPLv3 license](https://github.com/tdegeus/cppcolormap/blob/master/LICENSE). Any additions are very much appreciated, in terms of suggested functionality, code, documentation, testimonials, word-of-mouth advertisement, etc. Bug reports or feature requests can be filed on [GitHub](https://github.com/tdegeus/cppcolormap). As always, the code comes with no guarantee. None of the developers can be held responsible for possible mistakes.\n\nDownload: [.zip file](https://github.com/tdegeus/cppcolormap/zipball/master) | [.tar.gz file](https://github.com/tdegeus/cppcolormap/tarball/master).\n\n(c - [GPLv3](https://github.com/tdegeus/cppcolormap/blob/master/LICENSE)) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | [github.com/tdegeus/cppcolormap](https://github.com/tdegeus/cppcolormap)\n\n**Contributors**\n\n*   [Wolf Vollprecht](https://github.com/wolfv)\n\n# Usage from C++\n\n## Getting cppcolormap\n\n### Using conda\n\n```\nconda install -c conda-forge cppcolormap\n```\n\n### From source\n\n```bash\n# Download cppcolormap\ngit checkout https://github.com/tdegeus/cppcolormap.git\ncd cppcolormap\n\n# For CMake or pkg-config use\ncmake .\nmake install\n```\n\n## Usage\n\nThe principle interface is with these two functions:\n\n```cpp\n#include \u003ccppcolormap.h\u003e\n\nint main()\n{\n    std::cout \u003c\u003c cppcolormap::colormap(\"Reds\") \u003c\u003c std::endl;\n    std::cout \u003c\u003c cppcolormap::colorcycle(\"tue\") \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\nLists of colormaps and color-cycles can be found below.\n\nThe colormaps are stored as a matrix whereby each row contains the (R,G,B) colors. Each color value has a range `[0..1]`. The number of colors varies from map to map, but can be interpolated by specifying the number of colors you want:\n\n```cpp\n#include \u003ccppcolormap.h\u003e\n\nint main()\n{\n    std::cout \u003c\u003c cppcolormap::colormap(\"Reds\", 256) \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\nNote that the colorcycles are not interpolatable. Consequently the functions do have a size option. Note also that the colormaps and colorcycles can also be called directly, e.g.\n\n```cpp\n#include \u003ccppcolormap.h\u003e\n\nint main()\n{\n    std::cout \u003c\u003c cppcolormap::Reds() \u003c\u003c std::endl;\n    std::cout \u003c\u003c cppcolormap::Reds(256) \u003c\u003c std::endl;\n    std::cout \u003c\u003c cppcolormap::tue() \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\n## Find match\n\nTo find the closest match of each color of a colormap in another colormap you can use:\n\n```cpp\nxt::xtensor\u003csize_t,1\u003e idx = cppcolormap::match(cmap1, cmap2);\nxt::xtensor\u003csize_t,1\u003e idx = cppcolormap::match(cmap1, cmap2, cppcolormap::metric::euclidean);\n```\n\nThe following metrics can be used:\n\n*   euclidean (default)\n*   fast_perceptual\n*   perceptual\n\n## Compiling\n\n### Using CMake\n\nUsing *cppcolormap* the `CMakeLists.txt` can be as follows\n\n```cmake\ncmake_minimum_required(VERSION 3.1)\nproject(example)\nfind_package(cppcolormap REQUIRED)\nadd_executable(example example.cpp)\ntarget_link_libraries(example PRIVATE cppcolormap)\n```\n\nNote that the target *cppcolormap* includes the target *xtensor* (itself automatically enforcing the minimal C++14 standard), which is automatically searched using `find_package(cppcolormap)`.\n\nCompilation can then proceed using\n\n*   Unix:\n\n    ```\n    cmake .\n    make\n    ```\n\n*   Windows:\n\n    ```none\n    cmake -G\"NMake Makefiles\" .\n    nmake\n    ```\n\n[Download example \"CMakeLists.txt\"](./example/CMakeLists.txt)\n\n### Using pkg-config\n\nPresuming that the compiler is `c++`, compile using (Unix):\n\n```\nc++ `pkg-config --cflags cppcolormap` `pkg-config --cflags xtensor` -std=c++14 ...\n```\n\n### By hand\n\nPresuming that the compiler is `c++`, compile using (Unix):\n\n```\nc++ -I/path/to/cppcolormap/include -I/path/to/xtensor/include  -std=c++14 ...\n```\n\n# Usage from Python\n\n## Getting cppcolormap\n\n### Using conda\n\n```\nconda install -c conda-forge python-cppcolormap\n```\n\n### From source\n\n```bash\n# Download cppcolormap\ngit checkout https://github.com/tdegeus/cppcolormap.git\ncd cppcolormap\n\n# Compile and install\npython -m pip install .\n```\n\nNote that you have to install the dependencies *pybind11*, *xtensor*, and *pyxtensor* first.\n\n## Usage\n\nThere are two principle functions, each returns a 2-d NumPy array:\n\n```python\nimport cppcolormap as cm\n\n# number of colors in the colormap (optional, may be omitted)\nN = 256\n\n# specify the colormap as string\ncols = cm.colormap(\"Reds\", N)\ncols = cm.colorcycle(\"tue\")\n\n# or call the functions directly\ncols = cm.Reds(N)\ncols = cm.tue()\n```\n\n(see lists of colormaps and color-cycles below).\n\n## Find match\n\nTo find the closest match of each color of a colormap in another colormap you can use:\n\n```cpp\nidx = cm.match(cmap1, cmap2)\nidx = cm.match(cmap1, cmap2, cm.metric.perceptual)\n```\n\n(See metrics above.)\n\n## Example\n\n```python\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport cppcolormap as cm\n\nx, y = np.meshgrid(\n    np.linspace(0, 1, 100),\n    np.linspace(0, 1, 100))\n\nd = np.sqrt(x ** 2.0 + y ** 2.0)\n\nC = cm.Reds(256)\nC = np.c_[C, np.ones(C.shape[0])]\n\ncmap = matplotlib.colors.LinearSegmentedColormap.from_list('my_colormap', C)\n\nfig, ax = plt.subplots()\ncax = ax.imshow(d, cmap=cmap)\nplt.show()\n```\n\n# Available colormaps\n\n## ColorBrewer\n\n| Name     | Inverse colormap |\n|----------|------------------|\n| Accent   | Accent_r         |\n| Dark2    | Dark2_r          |\n| Paired   | Paired_r         |\n| Spectral | Spectral_r       |\n| Pastel1  | Pastel1_r        |\n| Pastel2  | Pastel2_r        |\n| Set1     | Set1_r           |\n| Set2     | Set2_r           |\n| Set3     | Set3_r           |\n| Blues    | Blues_r          |\n| Greens   | Greens_r         |\n| Greys    | Greys_r          |\n| Oranges  | Oranges_r        |\n| Purples  | Purples_r        |\n| Reds     | Reds_r           |\n| BuPu     | BuPu_r           |\n| GnBu     | GnBu_r           |\n| PuBu     | PuBu_r           |\n| PuBuGn   | PuBuGn_r         |\n| PuRd     | PuRd_r           |\n| RdPu     | RdPu_r           |\n| OrRd     | OrRd_r           |\n| RdOrYl   | RdOrYl_r         |\n| YlGn     | YlGn_r           |\n| YlGnBu   | YlGnBu_r         |\n| YlOrRd   | YlOrRd_r         |\n| BrBG     | BrBG_r           |\n| PuOr     | PuOr_r           |\n| RdBu     | RdBu_r           |\n| RdGy     | RdGy_r           |\n| RdYlBu   | RdYlBu_r         |\n| RdYlGn   | RdYlGn_r         |\n| PiYG     | PiYG_r           |\n| PRGn     | PRGn_r           |\n\n\u003e   Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.\n\u003e\n\u003e   Licensed under the Apache License, Version 2.0\n\u003e\n\u003e   [colorbrewer2.org](http://colorbrewer2.org)\n\n## matplotlib\n\n| Name          | Inverse colormap |\n|---------------|------------------|\n| spring        | spring_r         |\n| summer        | summer_r         |\n| autumn        | autumn_r         |\n| winter        | winter_r         |\n| bone          | bone_r           |\n| cool          | cool_r           |\n| hot           | hot_r            |\n| copper        | copper_r         |\n| hsv           | hsv_r            |\n| nipy_spectral | nipy_spectral_r  |\n| terrain       | terrain_r        |\n| seismic       | seismic_r        |\n| afmhot        | afmhot_r         |\n| magma         | magma_r          |\n| inferno       | inferno_r        |\n| plasma        | plasma_r         |\n| viridis       | viridis_r        |\n| jet           | jet_r            |\n\n\u003e   Copyright (c)  New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and\n\u003e   in the case of viridis) Eric Firing.\n\u003e\n\u003e   Licensed under the CC0 license / public domain dedication.\n\u003e\n\u003e   [GitHub/BIDS](https://github.com/BIDS/colormap)\n\n## monocolor\n\n| Name           | Inverse colormap | Source |\n|----------------|------------------|--------|\n| White          | -                |        |\n| Grey           | -                |        |\n| Black          | -                |        |\n| Red            | -                |        |\n| Blue           | -                |        |\n| tuedarkblue    | -                | [1]    |\n| tueblue        | -                | [1]    |\n| tuelightblue   | -                | [1]    |\n| tuewarmred     | -                | [1]    |\n| Apricot        | -                | [2]    |\n| Aquamarine     | -                | [2]    |\n| Bittersweet    | -                | [2]    |\n| Black          | -                | [2]    |\n| Blue           | -                | [2]    |\n| BlueGreen      | -                | [2]    |\n| BlueViolet     | -                | [2]    |\n| BrickRed       | -                | [2]    |\n| Brown          | -                | [2]    |\n| BurntOrange    | -                | [2]    |\n| CadetBlue      | -                | [2]    |\n| CarnationPink  | -                | [2]    |\n| Cerulean       | -                | [2]    |\n| CornflowerBlue | -                | [2]    |\n| Cyan           | -                | [2]    |\n| Dandelion      | -                | [2]    |\n| DarkOrchid     | -                | [2]    |\n| Emerald        | -                | [2]    |\n| ForestGreen    | -                | [2]    |\n| Fuchsia        | -                | [2]    |\n| Goldenrod      | -                | [2]    |\n| Gray           | -                | [2]    |\n| Green          | -                | [2]    |\n| GreenYellow    | -                | [2]    |\n| JungleGreen    | -                | [2]    |\n| Lavender       | -                | [2]    |\n| LimeGreen      | -                | [2]    |\n| Magenta        | -                | [2]    |\n| Mahogany       | -                | [2]    |\n| Maroon         | -                | [2]    |\n| Melon          | -                | [2]    |\n| MidnightBlue   | -                | [2]    |\n| Mulberry       | -                | [2]    |\n| NavyBlue       | -                | [2]    |\n| OliveGreen     | -                | [2]    |\n| Orange         | -                | [2]    |\n| OrangeRed      | -                | [2]    |\n| Orchid         | -                | [2]    |\n| Peach          | -                | [2]    |\n| Periwinkle     | -                | [2]    |\n| PineGreen      | -                | [2]    |\n| Plum           | -                | [2]    |\n| ProcessBlue    | -                | [2]    |\n| Purple         | -                | [2]    |\n| RawSienna      | -                | [2]    |\n| Red            | -                | [2]    |\n| RedOrange      | -                | [2]    |\n| RedViolet      | -                | [2]    |\n| Rhodamine      | -                | [2]    |\n| RoyalBlue      | -                | [2]    |\n| RoyalPurple    | -                | [2]    |\n| RubineRed      | -                | [2]    |\n| Salmon         | -                | [2]    |\n| SeaGreen       | -                | [2]    |\n| Sepia          | -                | [2]    |\n| SkyBlue        | -                | [2]    |\n| SpringGreen    | -                | [2]    |\n| Tan            | -                | [2]    |\n| TealBlue       | -                | [2]    |\n| Thistle        | -                | [2]    |\n| Turquoise      | -                | [2]    |\n| Violet         | -                | [2]    |\n| VioletRed      | -                | [2]    |\n| White          | -                | [2]    |\n| WildStrawberry | -                | [2]    |\n| Yellow         | -                | [2]    |\n| YellowGreen    | -                | [2]    |\n| YellowOrange   | -                | [2]    |\n\n1.  [Eindhoven University of Technology](http://www.tue.nl)\n2.  [LaTeX xcolor (dvipsnames)](https://en.wikibooks.org/wiki/LaTeX/Colors)\n\n# Available colorcycles\n\n## Xterm\n\n| Name  | Inverse colormap |\n|-------|------------------|\n| xterm | xterm_r          |\n\n\u003e   See [this site](https://jonasjacek.github.io/colors/)\n\n## Eindhoven University of Technology\n\n| Name | Inverse colormap |\n|------|------------------|\n| tue  | tue_r            |\n\n\n\u003e   Based on the corporate color scheme of the\n\u003e   [Eindhoven University of Technology](http://www.tue.nl).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdegeus%2Fcppcolormap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdegeus%2Fcppcolormap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdegeus%2Fcppcolormap/lists"}