title: Matplotlib scatter plot different colors in legend and plot
body: <p>I have a scatter plot of multiple y-values for the same x-value, in matplotlib (python 2.7). There are different colors for all the plotted y-values. See the plot below.</p>
  
  <p><img src="https://i.stack.imgur.com/ITXgU.png" alt="Errorbars of wrong symbol color than legend"></p>
  
  <p>Now, here is the code:</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  import pylab as pl
  import matplotlib.cm as cm
  
  # Generate test x, y and y_error values:
  df2a = pd.DataFrame(np.random.rand(10,5), columns = list('ABCDE'))
  df2a.insert(0,'x_var_plot',range(1,df2a.shape[0]+1))
  df2a_err = pd.DataFrame(np.random.rand(df2a.shape[0],df2a.shape[1]-1), columns = df2a.columns.tolist()[1:])
  df2a_err.insert(0,'x_var_plot',range(1,df2a.shape[0]+1))
  
  fig = plt.figure(1)
  ax = fig.add_subplot(111)
  ![Errorbars problem][1]
  colors = iter(cm.rainbow(np.linspace(0, 1, df2a.shape[1])))
  
  # Generate plot:
  for col in df2a.columns.values.tolist()[1:]:
      ax.errorbar(df2a['x_var_plot'], df2a[col], yerr=df2a_err[col], fmt='o')
      ax.scatter(df2a['x_var_plot'], df2a[col], color=next(colors), label=col)
  
  ax.legend(loc='best', scatterpoints = 1)
  plt.show()
  </code></pre>
  
  <p>The problem is that the colors in the plot symbols are completely different from the symbol colors in the legend. The problem occurs when I add errorbars. Something is wrong between the connection between the legend symbol color and the scatter plot error bars.</p>
  
  <p>Is there is a way to fix this so that the colors in the legend are the same as the colors of the scatter plot points, when I include error bars?</p>