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 brewer2mplVerified import paths — ran on the pinned version, not inferred.
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.
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)`).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.