Skip to main content

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

Project description

PyPalettes

pypalettes logo

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

This package is based on the R package paletteer, and all associated sub-packages (with original palettes) mentioned in the LICENSE file.



Installation

Note: pypalettes requires Python 3.9 or above.

You can install pypalettes directly from PyPI with:

pip install -U pypalettes



Quick start

Once pypalettes is imported, all the palettes are now accessible as any other colormap in matplotlib or seaborn via the palette or cmap arguments.

Categorical palette

import matplotlib.pyplot as plt
import seaborn as sns
import pypalettes

df = sns.load_dataset("penguins")

g = sns.lmplot(
    data=df, x="bill_length_mm", y="bill_depth_mm", hue="species", palette="Acadia"
)
g.set_axis_labels("Snoot length", "Snoot depth")
plt.show()

scatterplot example

Continuous palette

Note: the suffix _gradient is used to make the colormap a gradient.

import matplotlib.pyplot as plt
import pypalettes
import numpy as np

data = np.random.randn(20, 20)

plt.imshow(data, cmap="Sunset2_gradient")
plt.colorbar()
plt.show()

heatmap example

Your own palette

import matplotlib.pyplot as plt
from pypalettes import add_cmap
import numpy as np

add_cmap(
    colors=["#D57A6DFF", "#E8B762FF", "#9CCDDFFF", "#525052FF"],
    name="myOwnCmap",
    cmap_type="continuous",
)

x = np.linspace(0, 20, 1000)
y = np.sin(x)

plt.scatter(x, y, c=y, cmap="myOwnCmap")
plt.colorbar()
plt.show()

linechart example

Going further



Features

  • Add +2500 native palettes to matplotlib and seaborn
  • Load, customise and combine +2500 palettes
  • Create your own palettes

To find out more about using PyPalettes, use this PyPalettes guide.



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



Acknowledgements

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

A big thanks to Yan Holtz for:



Contributing

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

That said, adding more palettes is an easy way to make pypalettes better! Here’s the best way to get started:

First, open your code editor and navigate to parsers/list_manual_palettes.py. You’ll find a dictionary 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 type of palette. View examples here
  • "paletteer-kind": just put "unknown"

Then, run:

python parsers/main.py

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



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.4.tar.gz (368.4 kB view details)

Uploaded Source

Built Distribution

pypalettes-0.1.4-py3-none-any.whl (377.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypalettes-0.1.4.tar.gz
  • Upload date:
  • Size: 368.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pypalettes-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3457261c944a4c663035241c7d32001ec29e1e306aaeae1f5790fa5411e1c9d8
MD5 82a7cf8601d9e08516c936813ab3e663
BLAKE2b-256 0147ad7b00726945b1a11e759b2d80797edf0050987c37d41fdebcbd921a6107

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypalettes-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 377.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 332bfa5247b4279eac511d3e07e26e6260c088a3e360bb540898e3888c8894a7
MD5 c078da7aadb5c29c3db250be9ecd60ac
BLAKE2b-256 942f03709bc08c9a6e69e233b9bc248d7112b777bc5241104d190d8377d66f81

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