# How do I overlay a histogram with a plot of CDF?

data = Flatten[Import["speedtest1B.csv"]];
distrib = HistogramDistribution[data];
histogram = Histogram[data, ChartStyle -> {Blue}];
Export["speedtest1B.pdf",
Overlay[{
Histogram[
data,
ChartStyle -> {Blue},
ImageSize -> {500,500},
AxesLabel -> {"start-up time [ms]", "number of samples"}
],
DiscretePlot[
CDF[distrib, x],
{x, 0, Max[data]},
ImageSize -> {500,500},
Axes -> False
]
}
]
];


From the above I get:

I would like the plots to be properly aligned. Displaying the CDF x-axis on the right side of the plot would be a big plus. Also I don't realy get color-theaming so could someone please explain how to easily change the color od CDF to red.

-
Inside Overlay should be {...}, but you don't even need Overlay, use Show - see my answer. –  Vitaliy Kaurov Jan 30 '13 at 4:39

 data = 1000 RandomVariate[GammaDistribution[3, .5], 10^4];
distrib = HistogramDistribution[data];
Overlay[{DiscretePlot[CDF[distrib, x], {x, 0, Max[data]},
ImageSize -> {600, 400}, Frame -> {{False, True}, {False, False}},
FrameTicks -> {{None, Range[0.1, 1, .1]}, {None, None}},
ImagePadding -> {{50, 100}, {15, 25}}],
Histogram[data, ChartStyle -> Opacity[.5, Blue],
ImageSize -> {600, 400}, ImagePadding -> {{50, 100}, {15, 25}},
AxesLabel -> {Style["start-up time [ms]", 12],
Style["number of samples", 12]}]},
Alignment -> Center]


-
awesome! thank you! Any idea how to label the axes? Simple AxesLabel doesnt really work. –  JohnnyM Jan 30 '13 at 5:55
@JohnnyM, please see the update. (You need to adjust the values for the ImagePadding option to see the axes labels.) –  kguler Jan 30 '13 at 6:12
thanks! maybe you could help with my other question: mathematica.stackexchange.com/questions/18733/… I think it is quite basic. –  JohnnyM Jan 30 '13 at 6:16