title: Plotting multiple density curves on the same plot: weighting the subset categories in Python 3
body: <p>I am trying to recreate this density plot in python 3: math.stackexchange.com/questions/845424/the-expected-outcome-of-a-random-game-of-chess</p>
  
  <p><a href="https://i.stack.imgur.com/CuSlC.png" rel="nofollow noreferrer">End Goal: I need my density plot to look like this</a></p>
  
  <p><strong>The area under the blue curve is equal to that of the red, green, and purple curves combined</strong> because the different outcomes (Draw, Black wins, and White wins) are the subset of the total (All).</p>
  
  <p>How do I have python realize and plot this accordingly?</p>
  
  <p>Here is the .csv file of results_df after 1000 simulations pastebin.com/YDVMx2DL</p>
  
  <pre><code>from matplotlib import pyplot as plt
  import seaborn as sns
  
  black = results_df.loc[results_df['outcome'] == 'Black']
  white = results_df.loc[results_df['outcome'] == 'White']
  draw = results_df.loc[results_df['outcome'] == 'Draw']
  win = results_df.loc[results_df['outcome'] != 'Draw']
  
  Total = len(results_df.index)
  Wins = len(win.index)
  
  PercentBlack = "Black Wins ≈ %s" %('{0:.2%}'.format(len(black.index)/Total))
  PercentWhite = "White Wins ≈ %s" %('{0:.2%}'.format(len(white.index)/Total))
  PercentDraw = "Draw ≈ %s" %('{0:.2%}'.format(len(draw.index)/Total))
  AllTitle = 'Distribution of Moves by All Outcomes (nSample = %s)' %(workers)
  
  sns.distplot(results_df.moves, hist=False, label = "All")
  sns.distplot(black.moves, hist=False, label=PercentBlack)
  sns.distplot(white.moves, hist=False, label=PercentWhite)
  sns.distplot(draw.moves, hist=False, label=PercentDraw)
  plt.title(AllTitle)
  plt.ylabel('Density')
  plt.xlabel('Number of Moves')
  plt.legend()
  plt.show()
  </code></pre>
  
  <p>The code above produces density curves without weights, which I really need to figure out how to <strong>generate density curve weights accordingly</strong> as well as preserve my labels in the legend</p>
  
  <p><a href="https://i.stack.imgur.com/g5jG7.png" rel="nofollow noreferrer">density curves, no weights; help</a></p>
  
  <p>I also tried frequency histograms, that scaled the distribution heights correctly but I would rather keep the 4 curves overlaid on top of each other for a "cleaner" look...<strong>I don't like this frequency plot</strong> but this is my current fix at the moment. </p>
  
  <pre><code>results_df.moves.hist(alpha=0.4, bins=range(0, 700, 10), label = "All")
  draw.moves.hist(alpha=0.4, bins=range(0, 700, 10), label = PercentDraw)
  white.moves.hist(alpha=0.4, bins=range(0, 700, 10), label = PercentWhite)
  black.moves.hist(alpha=0.4, bins=range(0, 700, 10), label = PercentBlack)
  plt.title(AllTitle)
  plt.ylabel('Frequency')
  plt.xlabel('Number of Moves')
  plt.legend()
  plt.show()
  </code></pre>
  
  <p>If anyone can write the python 3 code that <strong>outputs the first plot with 4 density curves with correct subset weights as well as preserves the custom legend</strong> that show percentages, that would be much appreciated.</p>
  
  <p>Once the density curves are plotted with the correct subset weights, I am also interested in the python 3 code in <strong>finding the max point coordinates of each density curve</strong> that shows max frequency of moves once I scale it up to 500,000 iterations.</p>
  
  <p>Thanks</p>