Registry / data / brewer2mpl

brewer2mpl

JSON →
library1.4.1pypypiunverified

brewer2mpl is a Python package that provides access to the ColorBrewer2.org color maps. It allows users to retrieve sequential, diverging, and qualitative color palettes in various formats, including RGB 0-255, hex strings, and 0-1 normalized RGB triplets suitable for Matplotlib. The library is no longer actively maintained; its functionality has been superseded by the `Palettable` library. The current version is 1.4.1, released in 2014, and there are no further updates planned.

pip install brewer2mpl
INSTALL
IMPORT
SIG · BREWER2MPL
B
brewer2mpl
datapythonv1.4.1
Install
1.6s avg
Import
540ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.351s · 18.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.297s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

brewer2mpl
import brewer2mpl
import brewer2mpl

This quickstart demonstrates how to fetch a named qualitative color map, access its Matplotlib-compatible RGB colors (0-1 range), and print relevant information. The commented-out Matplotlib plotting code shows a simple way to visualize the retrieved colors.

import brewer2mpl import matplotlib.pyplot as plt # Get a qualitative color map named 'Set2' with 7 colors bmap = brewer2mpl.get_map('Set2', 'Qualitative', 7) # Access colors as 0-1 RGB triplets for Matplotlib colors_for_mpl = bmap.mpl_colors print(f"Color map name: {bmap.name}") print(f"Number of colors: {bmap.number}") print(f"Matplotlib compatible colors (0-1 RGB): {colors_for_mpl}") # Example of using colors in a Matplotlib plot (if matplotlib is installed) # plt.figure(figsize=(7, 1)) # for i, color in enumerate(colors_for_mpl): # plt.barh(0, 1, left=i, color=color) # plt.axis('off') # plt.title('Brewer2mpl Set2 Qualitative (7 colors)') # plt.show()
Debug
Known issues
deprecatedThe `brewer2mpl` library is no longer actively maintained or updated. Its development ceased in 2014, and it has been officially superseded by the `Palettable` library. Users are strongly encouraged to migrate to `Palettable` for ongoing support, new features, and broader palette options.
fix
Migrate to `Palettable`: `pip install palettable`. Update import statements (e.g., `from palettable.colorbrewer.qualitative import Set2_7` instead of `brewer2mpl.get_map('Set2', 'Qualitative', 7)`).
affects: 1.0.0 and above
gotchaWhen working with Matplotlib, ensure you use the correct color representation from a `BrewerMap` object. `bmap.colors` provides RGB as 0-255 integer triplets, while `bmap.mpl_colors` provides RGB as 0-1 float triplets, which is the standard expected by Matplotlib functions for discrete colors. `bmap.mpl_colormap` provides a `matplotlib.colors.LinearSegmentedColormap` object for continuous usage.
fix
For discrete color lists in Matplotlib, use `bmap.mpl_colors`. For a continuous colormap object, use `bmap.mpl_colormap`. Avoid using `bmap.colors` directly with Matplotlib functions that expect normalized values, as this will lead to incorrect color rendering.
affects: 1.0.0 and above
Upgrade
Version history
1.4.1latest on PyPI · released Sep 19, 2014
Audit
Dependencies
matplotliboptionalUsed for integration with plotting functionalities, especially when converting palettes to Matplotlib colormaps (e.g., via `bmap.mpl_colormap` or `bmap.mpl_colors`). While brewer2mpl itself has no hard dependencies, its primary use case involves Matplotlib.
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
brewer2mpl — pip install brewer2mpl · libregistry