{"id":4674,"library":"palettable","title":"Palettable","description":"Palettable is a Python library that provides a comprehensive collection of color palettes, including those from Colorbrewer2, Tableau, CartoColors, cmocean, and more. It is written in pure Python with no external dependencies and can supply color maps for Matplotlib or be used for web applications. The current version is 3.3.3, with an irregular release cadence and maintenance releases as needed.","status":"active","version":"3.3.3","language":"en","source_language":"en","source_url":"https://github.com/jiffyclub/palettable","tags":["color palettes","visualization","matplotlib","data visualization","color schemes"],"install":[{"cmd":"pip install palettable","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for generating matplotlib colormaps and for visualization functions like `show_discrete_image` or `save_continuous_image`.","package":"matplotlib","optional":true},{"reason":"Required for `show_as_blocks` function in IPython Notebooks.","package":"ipythonblocks","optional":true}],"imports":[{"note":"The library was renamed from `brewer2mpl` to `palettable` in version 2.0.0.","wrong":"import brewer2mpl","symbol":"Dark2_7","correct":"from palettable.colorbrewer.qualitative import Dark2_7"},{"note":"Palettes are imported directly by their name and number of colors from specific submodules (e.g., `colorbrewer.qualitative`, `matplotlib`).","symbol":"Viridis_256","correct":"from palettable.matplotlib import Viridis_256"}],"quickstart":{"code":"from palettable.colorbrewer.qualitative import Dark2_7\n\n# Access basic palette information\nprint(f\"Palette Name: {Dark2_7.name}\")\nprint(f\"Number of Colors: {Dark2_7.number}\")\n\n# Get colors in different formats\nprint(f\"RGB colors (0-255): {Dark2_7.colors}\")\nprint(f\"Hex colors: {Dark2_7.hex_colors}\")\nprint(f\"Matplotlib-compatible RGB (0-1): {Dark2_7.mpl_colors}\")\n\n# Example: Using with Matplotlib (requires matplotlib installed)\ntry:\n    import matplotlib.pyplot as plt\n    from matplotlib.colors import ListedColormap\n\n    # Create a matplotlib colormap from the palette\n    cmap = ListedColormap(Dark2_7.mpl_colors)\n\n    # Display the palette as an image\n    fig, ax = plt.subplots(figsize=(6, 1))\n    ax.imshow([[i for i in range(Dark2_7.number)]], cmap=cmap, aspect='auto')\n    ax.set_axis_off()\n    ax.set_title(f\"{Dark2_7.name} ({Dark2_7.number} colors)\")\n    plt.show()\nexcept ImportError:\n    print(\"Matplotlib not installed. Skipping visualization example.\")","lang":"python","description":"This quickstart demonstrates how to import a specific color palette, access its various color representations (RGB 0-255, Hex, Matplotlib-compatible RGB 0-1), and optionally visualize it using Matplotlib."},"warnings":[{"fix":"Update imports to `from palettable.<source>.<type> import <PaletteName>_<NumColors>`.","message":"The library was renamed from `brewer2mpl` to `palettable` in version 2.0.0 (released March 2015). Code using `import brewer2mpl` will fail.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Refer to the documentation or use tab-completion to find the exact palette names and their available color counts.","message":"Palettes are organized into submodules (e.g., `palettable.colorbrewer.qualitative`, `palettable.matplotlib`) and follow a naming convention of `<Name>_<number of colors>` (e.g., `Dark2_7`). Reversed palettes have an `_r` suffix.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `matplotlib` (for colormaps and image saving) or `ipythonblocks` (for IPython block displays) if you intend to use these specific features (`pip install matplotlib ipythonblocks`).","message":"While Palettable itself has no external *core* dependencies, certain visualization and display functions (e.g., `show_as_blocks`, `show_discrete_image`, `save_continuous_image`) require `ipythonblocks` or `matplotlib` to be installed separately.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}