One possible way is to use the options MeshFunctions
and Mesh
:
RegionPlot(x >= 2 && x <= 3 && y >= 2 && y <= 3, {x, 0, 4}, {y, 0, 4},
PlotPoints -> 100,
BoundaryStyle -> None,
PlotStyle -> Opacity(.3, Yellow),
MeshFunctions -> {# &, #2 &},
Mesh -> {{{2, Directive(Opacity(1), Red)}, {3,
Directive(Opacity(1), Cyan)}}, {{2,
Directive(Thick, Opacity(1), Purple)}, {3,
Directive(Thick, Opacity(1), Blue)}}},
BaseStyle -> Thick)
An alternative way is to use Graphics
(as suggested by MarcoB in comments):
Graphics({FaceForm(Opacity(.3, Yellow)), Rectangle({2, 2}, {3, 3}),
Thick, MapThread(List, {{Red, Cyan, Purple, Blue}, Line /@
{{{2, 2}, {2, 3}}, {{3, 2}, {3, 3}}, {{2, 2}, {3, 2}}, {{2, 3}, {3, 3}}}})},
PlotRange -> {{0, 4}, {0, 4}}, Frame -> True)
A more convenient way to avoid listing of line coordinates:
{lines, polygon} = MeshPrimitives(
BoundaryDiscretizeRegion(Rectangle({2, 2}, {3, 3}),
MaxCellMeasure -> Infinity), #) & /@ {1, 2};
Graphics({FaceForm(Opacity(.3, Yellow)), polygon,
Thick, MapThread(List, {{Purple, Cyan, Blue, Red}, lines})},
PlotRange -> {{0, 4}, {0, 4}}, Frame -> True)
same picture
Related Q/A: Different Boundary Style on each edge of 3D Plot