title: How to get N easily distinguishable colors with Matplotlib
body: <p>I need to make different amounts of line plots with Matplotlib, but I have not been able to find a colormap that makes it easy to distinguish between the line plots.
  I have used the brg colormap like this:</p>
  
  <pre><code>colors=brg(np.linspace(0,1,num_plots))
  </code></pre>
  
  <p>with</p>
  
  <pre><code>for i in range(num_plots):
      ax.step(x,y,c=colors[i])
  </code></pre>
  
  <p>With four plots, this could look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/hwdhZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwdhZ.png" alt=""></a></p>
  
  <p>Notice how hard it is to distinguish the colors of the top and bottom plots, which is especially bad if a legend is used.
  I've tried a lot of different colormaps like rainbow and jet, but with this setup, brg seems to give the best result for <code>num_plots</code> between 1 and 12.</p>
  
  <p>I did find this <a href="https://graphicdesign.stackexchange.com/questions/108733/how-to-get-10-different-colors-that-are-easily-recognizable">How to get 10 different colors that are easily recognizable</a> and this Wiki page <a href="https://en.wikipedia.org/wiki/Help:Distinguishable_colors" rel="nofollow noreferrer">Help:Distinguishable colors</a>, but I don't know if this can be used in any way..</p>
  
  <p>Is there an easy fix to this, or will I have to make do with this?</p>