How to make a custom divergent colormap?

asked 2014-09-18 07:49:34 -0600

balduin gravatar image

updated 2014-09-19 10:06:35 -0600

How can I make a custom diverging colormap in Sage? What I want is the same than the reverse seismic diverging colormap (Diverging Colormaps) but the blue value should be less intense (e. g. conflower blue [Hex color code: #6495ED]).

In the sage source code I found the following link Diverging Colormaps, which explains the divergent colormaps and has a python class in the attachments. But still I have no clue to make such a diverging colormap.

I have also tried to make it with a LinearSegementedColormap:

from pylab import *
startcolor = '#FF0000'
midcolor = '#FFFFFF'
endcolor = '#0030CC'
own_cmap1 = matplotlib.colors.LinearSegmentedColormap.from_list( 'own2', [startcolor, midcolor, endcolor] )
matrix_plot( matrix( [ [1,3,5,1], [2,4,5,6], [1,-3,5,7] ] ), cmap = own_cmap1, colorbar = True )

but the result is absolutely not what I want, because it goes too fast from red into pink.

edit retag flag offensive close merge delete