Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
Where is this "data set" you speak of? –  J. M. Jun 5 '13 at 2:51
add comment

1 Answer

up vote 6 down vote accepted

Here's an example:

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

Show[
     Histogram[data1, Automatic, "PDF"],
     SmoothHistogram[data2],
     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.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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