title: Plot histogram and density function curve on one chart
body: <p>I have a density function f, and I do MCMC sampling for it. To evaluate the goodness of the sampling, I need to plot the <code>hist</code> and <code>curve</code> within the same chart. The problem of</p>
  
  <pre><code>hist(samples);
  curve(dfun,add=TRUE);
  </code></pre>
  
  <p>is that they are on the different scale: the frequency of a certain bin is usually hundreds, while the maximum of a density function is about 1 or so. What I want to do is to configure two plots at the same height, with one y-axis on the left and the other on the right. Can anyone help? Thank you.</p>