title: Matrix normalization over multiple runs, what does this code do?
body: <p>I have several numpy matrices collected over some time. I now want to visualize these matrices and explore visual similarities among them. The matrices contain small numbers from 0.0 to 1.0.</p>
  <p>To compare them, I want to ensure that the same &quot;areas&quot; get colored with the same color, e.g. that 0.01 to 0.02 always is red, and 0.02 to 0.03 always is green. I have two question:</p>
  <p>I found another <a href="https://stackoverflow.com/questions/5552641/plotting-a-2d-matrix-in-python-code-and-most-useful-visualization">question</a> which has this code snippet:</p>
  <pre><code>a = np.random.normal(0.0,0.5,size=(5000,10))**2
  a = a/np.sum(a,axis=1)[:,None]  # Normalize
  
  plt.pcolor(a)
  </code></pre>
  <p>What is the effect of the second line, precisely the <code>[:,None]</code> statement. I tried normalizing a matrix by:</p>
  <pre><code>max_a = a/10# Normalize
  print(max_a.shape)
  plt.pcolor(max_a)
  </code></pre>
  <p>but there is not much visual difference compared to the visualization for the unnormalized matrix. When I then add the <code>[:,None]</code> statement I get an error</p>
  <pre><code>ValueError: too many values to unpack (expected 2)
  </code></pre>
  <p>which is expected since the shape now is <code>10,1,10</code>. I therefor want to know what the brackets do and how to read the statement.</p>
  <p>Secondly, and related, I want to make sure that I can visual compare the matrices. I therefor want to fix the &quot;colorization&quot;, e.g. the ranges when a color is green or red, so that I do not end up with 0 to 0.1 as green in plot A and with 0 to 0.1 as red in plot B. How can I fix the &quot;translation&quot; from floats to colors? Do I have to normalize each matrix with a same constant, e.g. 10? Or do I normalize them with an unique value -- do I even need normalization here?</p>