Adjusting matplotlib colormap to show simulation
<p>I'm building a little simulation based on this experiment:
<a href="https://www.youtube.com/watch?v=plVk4NVIUh8" rel="nofollow">https://www.youtube.com/watch?v=plVk4NVIUh8</a> , which shows the evolution of a bacteria over time.</p>

<p>I have initialized some bacteria with random resistance at the edge of a petri dish:</p>

<p><a href="http://i.stack.imgur.com/VSiDA.png" rel="nofollow"><img src="http://i.stack.imgur.com/VSiDA.png" alt="enter image description here"></a></p>

<p>As the bacteria spreads, the contrast from the non occupied space is less and less, after a 100 generation it becomes like this:
<a href="http://i.stack.imgur.com/kZvuc.png" rel="nofollow"><img src="http://i.stack.imgur.com/kZvuc.png" alt="enter image description here"></a> </p>

<p>I use plt.matshow(Map) to make the pictures, where Map is a 2D numpy array, with bacteria resistance values (always bigger than 0), the non occupied space is represented as 0. I tried different colormaps, but it did not help. My aim is to make the non occupied space some constant dark color,
the infected space some light color, with conrtast to notice the different resistance values.</p>

<p>Can you help me with that?</p>

<p>You could get a <a href="http://matplotlib.org/users/colormaps.html" rel="nofollow">colormap</a> with a dark color for low values, such as 'magma' and define, as Andreas suggested a 'vmin' value. e.g.</p>

<pre><code>import matplotlib.pyplot as plt
from scipy import rand

a = rand(10, 20) + 0.5
a[0, 0] = 0
cmap = plt.get_cmap('magma')
img = plt.pcolormesh(a, cmap=cmap, vmin=0,)
img.figure.show()
</code></pre>

<p><a href="http://i.stack.imgur.com/ZXBPt.png" rel="nofollow"><img src="http://i.stack.imgur.com/ZXBPt.png" alt="enter image description here"></a></p>

<p>Cheers!
S</p>

python numpy matplotlib simulation