title: How can I generate a colormap array from a simple array in matplotlib
body: <p>In some functions of <code>matplotlib</code>, we have to pass an <code>color</code> argument instead of a <code>cmap</code> argument, like <code>bar3d</code>.</p>
  
  <p>So we have to generate a <code>Colormap</code> manually. If I have a <code>dz</code> array like this:</p>
  
  <pre><code>dz = [1,2,3,4,5]
  </code></pre>
  
  <p>What I want is:</p>
  
  <pre><code>ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color=cm.jet(dz), zsort='average')
  </code></pre>
  
  <p>However, It does not work, it seems <code>Colormap</code> instances can only convert normalized arrays.</p>
  
  <pre><code>&gt;&gt;&gt; dz = [1,2,3,4,5]
  &gt;&gt;&gt; cm.jet(dz)
  array([[ 0.        ,  0.        ,  0.51782531,  1.        ],
         [ 0.        ,  0.        ,  0.53565062,  1.        ],
         [ 0.        ,  0.        ,  0.55347594,  1.        ],
         [ 0.        ,  0.        ,  0.57130125,  1.        ],
         [ 0.        ,  0.        ,  0.58912656,  1.        ]])
  </code></pre>
  
  <p>Of course, this is not what I want.</p>
  
  <p>I have to do things like this:</p>
  
  <pre><code>&gt;&gt;&gt; cm.jet(plt.Normalize(min(dz),max(dz))(dz))
  array([[ 0.        ,  0.        ,  0.5       ,  1.        ],
         [ 0.        ,  0.50392157,  1.        ,  1.        ],
         [ 0.49019608,  1.        ,  0.47754586,  1.        ],
         [ 1.        ,  0.58169935,  0.        ,  1.        ],
         [ 0.5       ,  0.        ,  0.        ,  1.        ]])
  </code></pre>
  
  <p>How ugly the code is!</p>
  
  <p>In <a href="http://matplotlib.org/api/colors_api.html#matplotlib.colors.Colormap" rel="noreferrer">matplotlib's document</a> it is said:</p>
  
  <blockquote>
    <p>Typically Colormap instances are used to convert data values (floats)
    from the interval [0, 1] to the RGBA color that the respective
    Colormap represents. For scaling of data into the [0, 1] interval see
    matplotlib.colors.Normalize. It is worth noting that
    matplotlib.cm.ScalarMappable subclasses make heavy use of this
    data->normalize->map-to-color processing chain.</p>
  </blockquote>
  
  <p>So why I can't use just <code>cm.jet(dz)</code>?</p>
  
  <p>Here are the imports that I am using</p>
  
  <pre><code>from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  import numpy as np
  from matplotlib import cm
  </code></pre>