Skip to content

Matplotlib colormaps have deprecated behavior

Created by: alurban

In downstream service software (particularly gwsumm and gwdetchar.omega) I am seeing the following warnings:

/path/to/lib/python3.8/site-packages/gwpy/plot/plot.py:395: MatplotlibDeprecationWarning: The 'cmap' parameter to Colorbar has no effect because it is overridden by the mappable; it is deprecated since 3.3 and will be removed two minor releases later.
    cbar = super().colorbar(mappable, **kwargs)

Matplotlib's release notes are somewhat confusing on the matter of how to address this, but AFAICT it appears we have to set the colormap from the mappable directly, something like:

mappable.set_cmap(cmap)
cbar = ax.colorbar(mappable, **kwargs)