Skip to main content

A large collection of color maps for Python

Project description

PyPalettes

pypalettes logo

A large (+2500) collection of color maps for Python.

All available palettes can be found on the dedicated website

You can find an introduction to PyPalettes in the Python Graph Gallery, with code samples and explanations about how to use this library in many different cases.



Installation

Note: pypalettes requires Python 3.9 or above.

You can install pypalettes directly from PyPI with:

pip install --upgrade pypalettes

Alternatively you can install the development version with:

pip install git+https://github.com/JosephBARBIERDARNAL/pypalettes.git



Quick start

Once the cmap is loaded, you can use it as any other color map in matplotlib or seaborn.

import matplotlib.pyplot as plt
from pypalettes import load_cmap
import seaborn as sns
import numpy as np

data = np.random.rand(10, 12)

cmap = load_cmap('Anemone', cmap_type='continuous')

sns.heatmap(data, cmap=cmap)
plt.show()

heatmap example



Getting started


  • Load a color map:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius')
cmap

Darjeeling2


  • Transform a qualitative color map into a continuous one:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius', cmap_type='continuous')
cmap

Darjeeling2


  • Invert a color map:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius', reverse=True)
cmap

Darjeeling2


  • Get hex values of a color map:
from pypalettes import get_hex
get_hex('pupitar')

['#7098C0FF', '#88C0E8FF', '#285880FF', '#B8E0F8FF', '#F8F8F8FF', '#404060FF', '#A8A8A8FF', '#C8C8D0FF', '#B04000FF']


  • Get rgb values of a color map:
from pypalettes import get_rgb
get_rgb('AirNomads')

[(255, 153, 51), (194, 72, 65), (255, 255, 51), (139, 91, 69), (135, 175, 209), (238, 176, 90), (219, 197, 160)]


  • Combine multiple colormaps
from pypalettes import get_hex
get_hex(['Alacena', 'Antique'])

['#693829FF', '#894B33FF', '#A56A3EFF', '#CFB267FF', '#D9C5B6FF', '#9CA9BAFF', '#5480B5FF', '#3D619DFF', '#405A95FF', '#345084FF', '#855C75FF', '#D9AF6BFF', '#AF6458FF', '#736F4CFF', '#526A83FF', '#625377FF', '#68855CFF', '#9C9C5EFF', '#A06177FF', '#8C785DFF', '#467378FF', '#7C7C7CFF']


More examples can be found in this introduction to PyPalettes.



Chart made with pypalettes

Click on the image to get the associated code!

choropleth map of europe stacked area chart of natural disasters
gapminder bubble chart lollipop chart with colormap and arrow



Contributing

Installation for contributions

  1. Fork the Repository: Fork this repository to your GitHub account.

  2. Clone the Repository:

    git clone https://github.com/JosephBARBIERDARNAL/pypalettes.git
    cd pypalettes
    
  3. Set Up a Virtual Environment:

    • Mac/Linux:
      python3 -m venv venv
      source venv/bin/activate
      
    • Windows:
      python -m venv venv
      venv\Scripts\activate
      
  4. Install Dependencies:

    pip install -r requirements-dev.txt
    pip install -e .
    
  5. Create a Feature Branch:

    git checkout -b feature-name
    
  6. Start Coding!

Since the core code of the library is currently quite short and simple, it does not require any major changes. However, if you feel like you have a good idea/suggestion, please open an issue.

BUT, more palettes is one easy way to make pypalettes better! Here is the best way to get started:

Then open your code editor and open parsers/list_manual_palettes.py. You will find a dictionnary of dictionnary of manually defined palettes. Add yours at the end with the following elements:

  • "name": the name of your palette
  • "palette": the colors of your palette, in the following format: ["['#123456', '#654321', '#162534']"]
  • "source": where does your palette come from? If you created it, your name or a link to your portfolio is valid!
  • "kind": the kind of your palette. View examples here
  • "paletteer-kind": just put "unknown"

For a large number of palettes, please open an issue first.



Acknowledgements

PyPalettes is highly inspired (and relies on for the first one) from

A big thanks to Yan Holtz for:



How data has been collected

99% of the palettes come from the Paletteer R package.

Learn more in the dedicated directory.



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypalettes-0.1.3.tar.gz (366.2 kB view details)

Uploaded Source

Built Distribution

pypalettes-0.1.3-py3-none-any.whl (375.6 kB view details)

Uploaded Python 3

File details

Details for the file pypalettes-0.1.3.tar.gz.

File metadata

  • Download URL: pypalettes-0.1.3.tar.gz
  • Upload date:
  • Size: 366.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.13

File hashes

Hashes for pypalettes-0.1.3.tar.gz
Algorithm Hash digest
SHA256 38479a97b22d8c4bada920ad158c98887467e5db0f57a6a9b3733af5ea7c6bdf
MD5 735349edcdcb5e3159a64a59762de5ae
BLAKE2b-256 499b81c44807ebf1d3aa95648bf6c4b4e51ffeba45fef4286868edb957a7eaec

See more details on using hashes here.

File details

Details for the file pypalettes-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pypalettes-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 375.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pypalettes-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 74565693137861605fff76b0ae559603bc78dc19562b9ca48ef73145345df62f
MD5 a7e52bbc2782407e8f102efb6d97522d
BLAKE2b-256 db83fc9cfb92bfafa1afa313d62e8eb4b4d1fb4cdce805ff1af92ba1e1ea5bba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page