title: How to color text by character in Python?
body: <p>I want to color a string, but character by character different. I have one array with the text and one array with values between -1 and 1, where -1 should represent "red" and 1 should be "green". 0 can be white, yellow or a fading color between red and green. </p>
  
  <p>Each character should have its color regarding the scoring.</p>
  
  <p>The data look like this:</p>
  
  <pre><code>array([['a', 'c', 'm', 'e', 't', 'e', 'l', 'l', 'm', 'e'],
     ['0.1716490432811229', '0.062389299621661884',
      '0.26545182258229466', '-0.07999088246625552',
      '-0.4499291603930515', '-0.7465421931327068', '-0.812006046307664',
      '-0.8443500193245104', '-0.865253671942029','-0.8697487071105282',]],
    dtype='&lt;U32')
  </code></pre>
  
  <p>I was able to generate the colors:</p>
  
  <pre><code>import matplotlib as mpl
  import matplotlib.cm as cm
  
  norm = mpl.colors.Normalize(vmin=-1, vmax=1)
  cmap = cm.RdYlGn
  x = 0.3
  
  m = cm.ScalarMappable(norm=norm, cmap=cmap)
  #print(m.to_rgba(x))
  
  color = m.to_rgba(ws)
  color
  </code></pre>
  
  <p>The result looks like this (it's r,g,b,a):</p>
  
  <pre><code>array([[ 0.87435602,  0.94709727,  0.57708574,  1.        ],
         [ 0.9561707 ,  0.98154556,  0.68904268,  1.        ],
         [ 0.83529412,  0.93048827,  0.5349481 ,  1.        ],
         [ 0.68627451,  0.86620531,  0.43852364,  1.        ],
         [ 0.46889658,  0.77131872,  0.39577086,  1.        ],
         [ 0.45905421,  0.76701269,  0.39469435,  1.        ],
         [ 0.07597078,  0.54809689,  0.2887351 ,  1.        ],
         [ 0.08796617,  0.57024221,  0.30026913,  1.        ],
         (truncated...)
  </code></pre>
  
  <p>The target environment is IPython or JupyterHub. The colored text could be as text(preferred), as image, as HTML or maybe as plotted dataframe/seaborn. But the text should be easily readable and may be 50 up to 100 characters log.</p>