Custom continuous color map in matplotlib
<p>I have read some questions on this subject but I have been unable to find a specific answer to my question.</p>

<p>Let consider the image below:</p>

<p><img src="https://i.stack.imgur.com/Xyd1W.png" alt="Color map example"></p>

<p>My goal is just to change the <em>limit colors</em> of the map, e.g. in this case the color map goes from dark red to dark blue, let's say I would like it to go from dark green to dark blue. Specifically, I would it to go from colors <code>#244162</code> to <code>#DCE6F1</code> (tonalities of blue) in the same continuous way as in the example above.</p>

<p>How is it possible to do this?</p>

<hr>

<p><strong>[EDIT]</strong></p>

<p>I have tried the following code:</p>

<pre><code>import matplotlib.pyplot as plt
import matplotlib.colors as clr

some_matrix = ...
cmap = clr.LinearSegmentedColormap('custom blue', ['#244162','#DCE6F1'], N=256)
plt.matshow(some_matrix, cmap=cmap)
</code></pre>

<p>But I get the error message <code>TypeError: list indices must be integers, not unicode</code>.</p>