title: Defining colors of Matplotlib 3D bar plot
body: <p>I can't figure out the right way to set a cmap (or colors) for a 3d bar plot in matplotlib in my iPython notebook. I can setup my chart correctly (28 x 7 labels) in the X and Y plane, with some random Z values. The graph is hard to interpret, and one reason is that the default colors for the x_data labels [1,2,3,4,5] are all the same. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>%matplotlib inline
  from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  import numpy as npfig = plt.figure(figsize=(18,12))
  
  ax = fig.add_subplot(111, projection='3d')
  
  x_data, y_data = np.meshgrid(np.arange(5),np.arange(3))
  z_data = np.random.rand(3,5).flatten()
  
  ax.bar3d(x_data.flatten(),
  y_data.flatten(),np.zeros(len(z_data)),1,1,z_data,alpha=0.10)
  </code></pre>
  
  <p>Which produces the following chart:</p>
  
  <p><a href="https://i.stack.imgur.com/yqMPE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yqMPE.png" alt="enter image description here"></a></p>
  
  <p>I don't want to define the colors manually for the labels x_data. How can I set up different 'random' cmap colors for each of the labels in x_data, still keeping the</p>
  
  <blockquote>
    <p>ax.bar3d</p>
  </blockquote>
  
  <p>parameter? Below is a variation using </p>
  
  <blockquote>
    <p>ax.bar</p>
  </blockquote>
  
  <p>and different colors, but what I need is <strong>ax.bar3d</strong>.
  <a href="https://i.stack.imgur.com/UyMjy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UyMjy.png" alt="enter image description here"></a></p>