# How to plot empty rectangle?

I know there is a Rectangle[] function, but it is always filled with some color. What I need is a rectangle, which is empty inside (only it's boundaries visible). I just need to overlay it on plotted function to indicate some of it's area.

• Did you try a Line yet? – Yves Klett Sep 11 '12 at 19:57
• Was just about to start doing it, but now I see Sjoerd's answer is exactly what I need. – alex Sep 11 '12 at 20:17

Use FaceForm[] to define the polygon's filling as empty. You set the polygon's outline color with EdgeForm[color]

Graphics[{EdgeForm[{Thick, Blue}], FaceForm[], Rectangle[]}]


or slightly more complex:

Graphics[
{
EdgeForm[{Thick, Hue[Random[]]}],
FaceForm[],
Rectangle[#, # + {4, 4}]
} & /@ RandomReal[{-10, 10}, {30, 2}]
] Just for completeness, it is hardly difficult to do this manually:

box[{x_, y_}, {X_, Y_}] :=
Line[{{x, y}, {x, Y}, {X, Y}, {X, y}, {x, y}}];

Graphics[{
{Red, Rectangle[{0, 0}, {1, 3}]},
{Blue, Rectangle[{2, 1}, {4, 2}]},
{Thick, box[{0, 0}, {1, 3}]}
}] Manual control allows for customizations:

box2[{x_, y_}, {X_, Y_}] :=
MapIndexed[
{Arrowheads[Sqrt[#2]/30], Arrow@#} &,
Partition[{{x, y}, {x, Y}, {X, Y}, {X, y}, {x, y}}, 2, 1]
]

Graphics[{
{Red, Rectangle[{0, 0}, {1, 3}]},
{Blue, Rectangle[{2, 1}, {4, 2}]},
{Thick, box2[{0, 0}, {1, 3}]}
` 