title: How to plot density plots with proportions on the y-axis?
body: <p>I am using the sm package in R to draw a density plot of several variables with different sample sizes, like this:</p>
  
  <pre><code>var1 &lt;- density(vars1[,1]) 
  var2 &lt;- density(vars2[,1]) 
  var3 &lt;- density(vars3[,1]) 
  
  pdf(file="density.pdf",width=8.5,height=8)
  plot(var1,col="BLUE")  
  par(new=T)
  plot(var2,axes=FALSE,col="RED")  
  par(new=T)
  plot(var3,axes=FALSE,col="GREEN")  
  dev.off()
  </code></pre>
  
  <p>The problem I'm having, is that I want the y-axis to show the proportions so I can compare the different variables with each other in a more meaningful way. The maxima of all three density plots are now exactly the same, and I'm pretty sure that they wouldn't be if the y-axis showed proportions. Any suggestions? Many thanks!</p>
  
  <p>Edit:</p>
  
  <p>I just learned that I should not plot on top of an existing plot, so now the plotting part of the code looks like this:</p>
  
  <pre><code>pdf(file="density.pdf",width=8.5,height=8)
  plot(var1,col="BLUE")  
  lines(var2,col="RED")  
  lines(var3,col="GREEN")  
  dev.off()
  </code></pre>
  
  <p>The maxima of those lines however are now very much in line with the sample size differences. Is there a way to put the proportions on the y-axis for all three variables, so the area under the curve is equal for all three variables? Many thanks!</p>