Skip to main content

brewer2mpl

NOTICE

brewer2mpl is now Palettable! brewer2mpl will no longer be updated, but will stay available here for the foreseeable future.

PyPI

brewer2mpl is a pure Python package for accessing colorbrewer2.org color maps from Python. With brewer2mpl you can get the raw RGB colors of all 165 colorbrewer2.org color maps. The color map data ships with brewer2mpl so no internet connection is required.

For more information and to view some of the color maps see the wiki at https://github.com/jiffyclub/brewer2mpl/wiki.

Color Maps

colorbrewer2.org has 3 map types: sequential, diverging, and qualitative. Each color map has between 3 and 12 defined colors.

Examples

Listing Color Maps

List all of the available color maps:

brewer2mpl.print_maps()

List maps by type:

brewer2mpl.print_maps('sequential')

Filter by number of colors defined:

brewer2mpl.print_maps('qualitative', 6)

Get a Color Map

Color maps are accessed by name, type, and number:

bmap = brewer2mpl.get_map('Paired', 'Qualitative', 5)

If you want a color map reversed from how it is given by colorbrewer2.org set the reverse keyword to True:

bmap = brewer2mpl.get_map('Paired', 'Qualitative', 5, reverse=True)

BrewerMap Objects

Color maps are represented by BrewerMap objects. They have a few useful attributes:

# colorbrewer2.org url.
bmap.colorbrewer2_url

# colorbrewer2.org name
bmap.name

# number of defined colors
bmap.number

# colors as a list of RGB 0-255 triplets
bmap.colors

# colors as a list of hex strings
bmap.hex_colors

# colors as a list of RGB 0-1 triplets (as used by matplotlib)
bmap.mpl_colors

# matplotlib color map
bmap.mpl_colormap

To launch your browser and see a color map at colorbrewer2.org use the colorbrewer2 method:

bmap.colorbrewer2()

The matplotlib color maps are created using matplotlib.colors.LinearSegmentedColormap.from_list. If you want to pass options to that method use the BrewerMap.get_mpl_colormap method:

cmap = bmap.get_mpl_colormap(N=1000, gamma=2.0)

Direct Access

If you know the color map you want there is a shortcut for direct access. You can import the sequential, diverging, or qualitative modules from brewer2mpl. On the module namespace are dictionaries containing BrewerMap objects keyed by number of defined colors.

Say you want the Dark2 qualitative color map with 7 colors. To get it directly you can do:

from brewer2mpl import qualitative
bmap = qualitative.Dark2[7]

There is also a special key ‘max’ for each name that points to the color map with the most defined colors:

from brewer2mpl import sequential
bmap = sequential.YlGnBu['max']

Metadata

Release files for brewer2mpl 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for brewer2mpl 1.4.1
File Size Uploaded
brewer2mpl-1.4.1.zip 29.3 kB Details
brewer2mpl-1.4.1.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for brewer2mpl 1.4.1
File Interpreter ABI Platform
brewer2mpl-1.4.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 77.0 kB

Release files / brewer2mpl-1.4.1.zip

Download URL brewer2mpl-1.4.1.zip
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7f013109a2351b91d507c1e79c4fcfb001bdd754f70767baa635f1e80ac16d6d
BLAKE2b-256 checksum
How to use checksums
57eae9717759fe753d3de100d91a832ae24dae33ea08b2c350eb791627f15c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / brewer2mpl-1.4.1.tar.gz

Download URL brewer2mpl-1.4.1.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2e094d1bea766885aa77e4ed40cc718af6458a1d5e08cc87a5f453c6095b1b1c
BLAKE2b-256 checksum
How to use checksums
fafd838695792e82978a708fc5ca6ad5d085923d8d76f5e01875078e837827cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / brewer2mpl-1.4.1-py2.py3-none-any.whl

Download URL brewer2mpl-1.4.1-py2.py3-none-any.whl
Size 24.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f89a795efc810fdbec359902d388980711604cc32907445ba1bc45f699d3fe81
BLAKE2b-256 checksum
How to use checksums
845700c45a199719e617db0875181134fcb3aeef701deae346547ac722eaaf5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.4.1 This release

3 release files

1.4

3 release files

1.3.2

2 release files

1.3.1

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page