def coolwarm_transparent(max_alpha=0.7, opaque_perc=30, transparent_perc=8):
    """Modify the coolwarm color scale to have full transparency around the middle."""
    import numpy as np
    import matplotlib.pylab as pl
    from matplotlib.colors import ListedColormap
    cmap = pl.cm.coolwarm
    my_cmap = cmap(np.arange(cmap.N))
    _20perc = cmap.N * opaque_perc // 100
    midpoint = cmap.N // 2 + 1
    _10perc = cmap.N * transparent_perc // 100
    alpha = np.ones(cmap.N) * max_alpha
    alpha[midpoint - _10perc:midpoint + _10perc] = 0
    alpha[_20perc:midpoint - _10perc - 1] = np.linspace(max_alpha, 0, len(
        alpha[_20perc:midpoint - _10perc - 1]))
    alpha[midpoint + _10perc:-_20perc] = np.linspace(0, max_alpha, len(
        alpha[midpoint + _10perc:-_20perc]))
    my_cmap[:, (-1)] = alpha
    return ListedColormap(my_cmap)
