# Overlay Rectangle on a ListPlot

I have a ListPlot of 100 data points in the range of 0 and 1. Now I'm trying to find a way to overlay (four) rectangles onto the listplot in 0.25 steps horizontally. Essentially I just have BinLists and try to visualize the Bins on the ListPlot with rectangles.

I drew a nice little picture with paint (since I can't draw it in mathematica yet :)) which hopefully makes it a little more clearer..I only drew three rectangles..

It seems somehow complicated to me and I don't get it to work (except with paint ^^), can someone help me out?

-
You might want to take a look at GridLines and its option GridLinesStyle :) I don't have Mathematica right now but by playing around with these two you should be able to have what you want :) –  Öskå Apr 19 at 19:47
Try Epilog->{Rectangle[...]} too. –  Kuba Apr 19 at 20:31

1. Use Epilog:

ListPlot[RandomInteger[50, 100],
Epilog -> {EdgeForm[{Thick, Gray}], Opacity[.2], Blue,
(* or use MapThread[Rectangle, {Thread[{0, Range[0, 40, 10]}],
Thread[{100, Range[10, 50, 10]}]}] instead of Rectangle@@@Thread[...]  *)


2. Use GridLines:

ListPlot[RandomInteger[50, 100], GridLines -> {{100}, Range[0, 50, 10]}]


3. Overlay ListPlot with Histogram using a constant height specification:

data = RandomInteger[50, 100];
bins = Range[0, 50, 10];
(* use a constant function for the third argument of Histogram *)
Show[ListPlot[data], Histogram[data, {bins}, 100 & /@ # &, BarOrigin -> Left,
ChartStyle -> Opacity[.3]]]


-
Works! Thank you –  holistic Apr 20 at 12:26