title: Visualizing line density using a color map, versus alpha transparency
body: <p>I want to visualize 200k-300k lines, maybe up to 1 million lines, where each line is a cumulative sequence of integer values that grows over time, one value per day on the order of 1000 days. the final values of each line range from 0 to 500.</p>
  
  <p>it’s likely that some lines will be appear in my population of lines 1000s of times, others 100s, others 10s of times, and some outliers will be unique. For plotting large numbers of points in an xy plane, alpha transparency can be a solution in some cases, but isn’t great if you want to be able to robustly distinguish overplot density. A solution that scales more powerfully is to use something like hexbin, which bins the space and allows you to use a color map to plot density of points in each bin.</p>
  
  <p>I haven’t been able to find a ready-made solution in python (ideally) or R for doing the analogous thing for plotting lines instead of points.</p>
  
  <p>The following code demonstrates the issue using a small sample (n=1000 lines): can anyone propose how I might drop the alpha value approach in favor of a solution that allows me to introduce a color map for line density, using a transform I can control?</p>
  
  <pre><code>df = pd.DataFrame(np.random.randint(2,size=(100,1000)))
  df.cumsum().plot(legend=False, color='grey', alpha=.1, figsize=(12,8))
  </code></pre>
  
  <p><strong>in response to request:</strong> this is what a sample plot looks like now; in the wide dark band, 10 overplots full saturates the line, so that segments of lines overplotted 10,100, and 1000 times are indistinguishable<br>
  <a href="https://i.stack.imgur.com/hu920.png" rel="nofollow"><img src="https://i.stack.imgur.com/hu920.png" alt="enter image description here"></a></p>