title: matplotlib: change marker color based on label value
body: <p>I'm drawing a 3D scatterplot, and intend to give different color to each marker based on the value of y-axis (country) label. I have the following code. The colors of markers aren't what they need to be. I think I'm doing something wrong or in-efficient in the for loop. Can you point out the mistake that I'm making? </p>
  
  <pre><code>from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  import numpy as np    
  
  src = ['facebook', 'google', 'amazon','facebook','facebook','google']
  year = [2014,2014,2013,2013,2012,2013]
  country = ['uk','ru','de','us','uk','us']
  avg = [154,267,187,312,274,439]
  colors = {'uk' : 'b',
            'de' : 'y',
            'ru' : 'r', 
            'us' : 'c'}
  
  unique_src, idx_src = np.unique(src, return_inverse=True)
  unique_cty, idx_cty = np.unique(country, return_inverse=True)
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  for col, val in zip(colors, country):
      ax.scatter(idx_src, idx_cty, year, s=avg, c=colors[val])
  plt.yticks(range(len(unique_cty)), unique_cty, rotation=340)
  plt.xticks(range(len(unique_src)), unique_src, rotation=45, horizontalalignment='right')
  ax.set_zticks(np.unique(year))
  plt.show()
  </code></pre>
  
  <p>Also, when calling the scatter function, I can't write:<br> 
      <code>ax.scatter(source, country, year, s=avg, c=colors[val])</code><br><br>
  as I get the following error message:<br> </p>
  
  <blockquote>
    <p>ValueError: could not convert string to float: facebook</p>
  </blockquote>
  
  <p>Why is that so? I am using matplotlib version 2.1.2</p>