How can we draw Histogram and SmoothHistogram together for two data sets?. I'd like to show the first data set using Histogram, and the second using SmoothHistogram.


Here's an example:

data1 = RandomVariate[NormalDistribution[0, 1], 100];
data2 = RandomVariate[NormalDistribution[1, 1], 100];

     Histogram[data1, Automatic, "PDF"],
     PlotRange -> All

histogram and smooth histogram

The important bits are:

  • using "PDF" for the histogram to match the smooth histogram in height (otherwise the histogram will show counts, and completely dwarf the other plot).
  • using Show with PlotRange -> All to combine the plots, and make sure each part is shown completely.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.