I would like to make a plot which satisfies the following:
- Formost it should contain the Histogram of the data, with an overlay of the PDF
- Two y-axes, the left being the count for the elements in the bin of the Histogram, the right being the Probability density for the PDF
- Should show the "fit" of the PDF to the histogram of the data (by being at the same scale)
data = RandomVariate[GumbelDistribution[], 1000];
While Histogram
has an option to render the discretized PDF of the data, I rather see the smooth fitted version and the original.
Clearly this will use some combination of Show
as to show the overlay for the discretized PDF and the smooth PDF one can type:
dist = SmoothKernelDistribution[data, "StandardGaussian"];
Show[Histogram[data, Automatic, "PDF"],
SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Blue],
Plot[PDF[dist, x], {x, -7, 3}, PlotStyle -> Red]]
So how to get the regular Histogram[data]
and the SmoothHistogram[data, Automatic, "PDF"]
on the same plot, with the same kind of overlay we see above, but with their respective y-axes?
Comments
Post a Comment