Choose a Colormap for your Plot#

This is an example of what colormaps are available in Py-ART, and how to add them to your own plots.


# Author: Max Grover (
# License: BSD 3 clause

import matplotlib.pyplot as plt
import numpy as np

import pyart
from pyart.testing import get_test_data

Plot the available colormaps

Let’s see which colormaps are available directly from Py-ART! We use a helper function from matplotlib to plot this.

# Setup some helper functions and ranges to visualize our colormaps, from matplotlib
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))

def plot_color_gradients(cmap_category, cmap_list):
    # Create figure and adjust figure height to number of colormaps
    nrows = len(cmap_list)
    figh = 0.35 + 0.15 + (nrows + (nrows - 1) * 0.1) * 0.22
    fig, axs = plt.subplots(nrows=nrows, figsize=(6.4, figh))
    fig.subplots_adjust(top=1 - 0.35 / figh, bottom=0.15 / figh, left=0.4, right=0.99)

    axs[0].set_title(cmap_category + " Colormaps", fontsize=14)

    for ax, cmap_name in zip(axs, cmap_list):
        ax.imshow(gradient, aspect="auto", cmap=f"pyart_{cmap_name}")

    # Turn off *all* ticks & spines, not just the ones with colormaps.
    for ax in axs:

Colorblind Friendly Colormaps

We recommend starting with these colorblind friendly colormaps. These colormaps are the most inclusive, and should be used where possible.

    "Colorblind Friendly",
    ["LangRainbow12", "HomeyerRainbow", "balance", "ChaseSpectral", "SpectralExtended"],
Colorblind Friendly Colormaps

Perceptually Uniform Colormaps

More generally, perceptually uniform colormaps are colormaps where the lightness value increases monotonically through the colormaps.

Sequential Colormaps

Diverging Colormaps

Diverging colormaps are helpful when showing positive and negative values. This is when the 0 value is meaningful (ex. velocity)

Diverging Colormaps

Field-Specific Colormaps

There are some colormaps that useful for specific fields, such as “BlueBrown10” for terrain, or NWSRef for the National Weather Service reflectivity field

    "Field-specific ",
Field-specific  Colormaps

Plot Using a Colormap from Matplotlib

Now, we can apply one of these colorbars to plot and compare to a colormap from matplotlib, starting with the matplotlib example.

# Read in a sample cfradial file
radar_file = get_test_data("")
radar =

# Setup a display to plot the data
display = pyart.graph.RadarDisplay(radar)

# Start by plotting a regular matplotlib colormap (Spectral_r)
display.plot("reflectivity_horizontal", vmin=-32, vmax=64.0, cmap="Spectral_r")
xsapr-sg 0.5 Deg. 2011-05-20T06:42:11Z  Equivalent reflectivity factor

Plot Using a Colormap from Py-ART

Let’s use one of our Py-ART’s colorbars now! We need to remember to add the pyart_ string in front of the colormap, as shown below. Setup a display to plot the data

display = pyart.graph.RadarDisplay(radar)

# Start by plotting a regular matplotlib colormap (Spectral_r)
    "reflectivity_horizontal", vmin=-32, vmax=64.0, cmap="pyart_HomeyerRainbow"
xsapr-sg 0.5 Deg. 2011-05-20T06:42:11Z  Equivalent reflectivity factor

Total running time of the script: ( 0 minutes 2.967 seconds)

Gallery generated by Sphinx-Gallery