I think it is simpler to make the colormap yourself, especially when so few colors are involved. This one is orange-white-blue.
cdict = {'red': [ (0.0, 0.0, 0.0),
(0.475, 1.0, 1.0),
(0.525, 1.0, 1.0),
(1.0, 1.0, 1.0)
],
'green': [ (0.0, 0.0, 0.0),
(0.475, 1.0, 1.0),
(0.525, 1.0, 1.0),
(1.0, 0.65, 0.0)
],
'blue': [ (0.0, 1.0, 1.0),
(0.475, 1.0, 1.0),
(0.525, 1.0, 1.0),
(1.0, 0.0, 0.0)
]
}
rwb_cmap = matplotlib.colors.LinearSegmentedColormap(name = 'rwb_colormap', colors = cdict, N = 256)
A colormap is a dictionary for the RGB values. For each color, a list of tupples gives the different segments. Each segment is a point along the z-axis, ranging from 0 to 1. The colors for the levels is interpolated from these segments.
segment z-axis end start
i z[i] v0[i] v1[i]
i+1 z[i+1] v0[i+1] v1[i+1]
i+2 z[i+2] v0[i+2] v1[i+2]
Levels between z[i]
and z[i+1]
will have colors between v1[i]
and v0[i+1]
etc. This makes it possible to 'jump' colors. v0[0]
and v1[-1]
are not used. You can use as many segments as you want. (adapted from here: http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap)
N
is the number of quantization levels. So for N = 256
it will interpolate the map for 256 levels. I use 256 out of laziness. I guess you have to be careful when you set N = 6
and you make 4 contours.
The 0.475 and 0.525 are to ensure that the middle contour is truly white. For the levels [-1.5, -0.5, 0.5, 1.5]
the fill is now orange-white-blue. If I had used 0.5 instead the middle level would be an interpolation of blue-ish and orange-ish.
The RGB code for orange is 255-165-0 or 1-0.65-0 if the scale is 0-1.