JosephBARBIERDARNAL / pypalettes

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

Home Page:https://python-graph-gallery.com/color-palette-finder/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pypalettes

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

All available palettes can be found on the dedicated website



Installation

pip install pypalettes



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
import seaborn as sns
from pypalettes import load_cmap
import numpy as np

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

cmap = load_cmap('Anemone')

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', type='continuous')
cmap

Darjeeling2


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

Darjeeling2


  • Reverse and continuous:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius', reverse=True, type='continuous')
cmap

Darjeeling2


  • Keep only the first 3 colors of a color map:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius', keep_first_n=3)
cmap

Darjeeling2


  • Keep only specific colors of a color map:
from pypalettes import load_cmap
cmap = load_cmap('Chaetodon_sedentarius', keep=[True, True, False, False, True])
cmap

Darjeeling2


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

random


  • 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)]


More examples can be found in the how to use notebook



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



Related projects

pypalettes is highly inspired from the R package paletteer and the python package palettable.



How data has been collected

Learn more in the dedicated directory



About

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

https://python-graph-gallery.com/color-palette-finder/

License:MIT License


Languages

Language:Python 100.0%