title: Adjusting the Line Colors in a Legend using matplotlib
body: <p>I'm using the following code to generate a plot with a large number of overplotted lines in Python using matplotlib:</p>
  
  <pre><code>def a_run(n, t, s):
      xaxis = np.arange(t, dtype=float)
      #Scale x-axis by the step size
      for i in xaxis:
          xaxis[i]=(xaxis[i]*s)
      for j in range(n):
          result = a_solve(t,s)
          plt.plot(result[:,1], color = 'r', alpha=0.1)
  
  def b_run(n, t, s):
      xaxis = np.arange(t, dtype=float)
      #Scale x-axis by the step size
      for i in xaxis:
          xaxis[i]=(xaxis[i]*s)
      for j in range(n):
          result = b_solve(t,s)
          plt.plot(result[:,1], color = 'b', alpha=0.1)
  
  a_run(100, 300, 0.02)
  b_run(100, 300, 0.02)   
  
  plt.xlabel("Time")
  plt.ylabel("P")
  plt.legend(("A","B"), shadow=True, fancybox=True) Legend providing same color for both
  plt.show()
  </code></pre>
  
  <p>This yields a plot like this:</p>
  
  <p><img src="https://i.stack.imgur.com/mqNPd.png" alt="enter image description here"></p>
  
  <p>The problem is the legend - because the lines are plotted with very high transparency, so are the legend lines, and that's very difficult to read. Additionally, it's plotting what I suspect are the "first two" lines, and both are red, when I need one red and one blue.</p>
  
  <p>I can't see any means of adjusting the line colors in Matplotlib like I would in say, the R graphics libraries, but does anyone have a solid workaround?</p>