Although I'm a bit late in answering this, I thought it's worth pointing out for completeness that there's actually a built-in function that is basically designed to do exactly what this question asks for: ErrorListPlot
as shown below where I just modify the given definition slightly in the first few lines:
Needs["ErrorBarPlots`"]
lp3 = ErrorListPlot[{#, ErrorBar[{}]} & /@ #1,
ErrorBarFunction ->
Function[{coords, errs}, {EdgeForm[Orange], LightOrange,
Rectangle[coords - #2/2, coords + #2/2]}],
AspectRatio -> 1, AxesOrigin -> {0, 0},
PlotStyle -> Hue /@ RandomReal[1, {Length@#1}],
Epilog -> {GrayLevel[.3], PointSize[.02], Point@#1, Thick,
Line@#1}, Frame -> True, FrameTicks -> All] &;
The function allows you to specify the option ErrorBarFunction
, and there is an example in the documentation showing how a rectangle can be constructed based on the errors in the data. Here I adapted that example to use a constant error in both horizontal and vertical directions.
Here is a set of test data - using differently scaled real numbers instead of integers:
data = {30, 10} # & /@ RandomReal[1, {15, 2}]
(*
==> {{15.0817, 8.63497}, {29.1274, 4.68834}, {3.86173,
2.3385}, {14.3022, 0.452592}, {2.81023, 9.56299}, {27.9932,
1.82105}, {1.35937, 0.0468926}, {9.20839, 2.01352}, {2.8601,
7.20318}, {11.0419, 1.71997}, {19.9694, 6.43578}, {10.9362,
6.84062}, {6.76464, 8.23109}, {21.5031, 4.1016}, {28.083, 6.58259}}
*)
lp3[data, 1]
Edit
Since the original question had variable colors, I should also add that to my solution. Here I color the edge according to the distance from the origin, and the inside according to the angle with the $x$ axis:
lp4 = ErrorListPlot[{#, ErrorBar[{}]} & /@ #1,
ErrorBarFunction ->
Function[{coords, errs}, {EdgeForm[Hue[Norm[coords]/20]],
Hue[2/Pi ArcTan @@ coords],
Rectangle[coords - #2/2, coords + #2/2]}], AspectRatio -> 1,
AxesOrigin -> {0, 0},
Epilog -> {GrayLevel[.3], PointSize[.02], Point@#1, Thick,
Line@#1}, Frame -> True, FrameTicks -> All] &;
lp4[data, 2]
Rectangle[]
. $\endgroup$ListPlot
and using Graphics primitives directly. $\endgroup$Graphics
that define the plot markers: instead ofGraphics@{Rec..}
useGraphics[{Rectangle[]},AspectRatio->.5
(say). $\endgroup$