I have Sea Ice Concentration data around Antarctica that range between -40 and +40 (see attached Figure) but I would like for the values between +10 and -10 to appear white in my map and colorbar because they do not represent sea ice concentration (they appear light green and light blue in the current Figure).
I do not want to exclude them from my array but rather want to assign them a specific color (in this case, white) and keep the jet colorscale for the other values.
I have looked at multiple other questions (i.e. How to change colorbar's color (in some particular value interval)?; Python matplotlib change default color for values exceeding colorbar range; **Reset default matplotlib colormap values after using 'set_under' or 'set_over')
but have not managed to apply those to my case.
I have tried to use 'set under','set over', 'set.bad' but have not managed to get what I would like. I have also tried to create my own colormap but haven't been successful either.
Would anyone be able to help?
Thanks.
UPDATE:
I have adapted the code from 'stackoverflow.com/a/41815114/5103802' (see Updated Code below) but my colors are not white for values [+10 -10] and 'jet' for above +10 and below -10 (see Figure below). The 'tmap' object seems to have messed up the colorscale. Any idea on how I could get the jet colorscale and leave the interval between -10 and +10 white?
Thanks for your help.
Updated code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors
from mpl_toolkits.basemap import Basemap, cm, rcParams
HIGH_86 = a.variables['high_86'][:]
n=40
x = 10
lower = plt.cm.seismic(np.linspace(1-x, 0, n))
upper = plt.cm.seismic(np.linspace(0, x, n))
white1 = plt.cm.seismic(np.ones(10)*x)
white2 = plt.cm.seismic(np.ones(10)*-(x))
colors = np.vstack((lower, white1, white2, upper))
tmap = matplotlib.colors.LinearSegmentedColormap.from_list('terrain_map_white', colors)
x = HIGH_86
lats = a.variables['latitude'][:]
lons = a.variables['longitude'][:]
lons, lats = np.meshgrid(lons,lats)
fig, ax = plt.subplots()
m2 = Basemap(projection='spstere',boundinglat=-50,lon_0=180,resolution='l')
CS2 = m2.contourf(lons,lats,x,cmap=tmap,latlon=True)
cbar = m2.colorbar(CS2,location='right', pad="12%")
m2.drawparallels(np.arange(-90.,99.,60.),labels=[False,False,False,False])
m2.drawmeridians(np.arange(-180.,180.,90.),labels=[True,False,False,True])
m2.drawcoastlines()
m1.fillcontinents(color='grey')
plt.title('SIE Anomaly')
plt.show()