Drawing a RegionPlot from a Table of Values
ListContourPlot[matrix, Contours -> (Union[Flatten@matrix] - 1/2),
ContourShading -> None, ScalingFunctions -> {None, "Reverse"}]
Update: " a way to make the lines on the contour plot show the step shape as in the real table":
contours = ComponentMeasurements[matrix, "Contours"];
Graphics[Values @ contours]
ArrayPlot[matrix, ColorFunction -> "Rainbow",
Epilog -> {Thick, Values @ ComponentMeasurements[matrix, "Contours"]},
FrameTicks -> All]
Edit
matrix = Array[RandomChoice[Range[5]] &, {10, 10}]; Table[
RegionPlot[RegionUnion[Rectangle /@ Position[matrix, i]],
PlotPoints -> 180, BoundaryStyle -> None,
PlotStyle -> RandomColor[]], {i, 1, 5}]
Or
matrix = Array[RandomChoice[Range[5]] &, {10, 10}];
Table[Graphics[{EdgeForm[Blue], FaceForm[RandomColor[]],
Rectangle /@ Position[matrix, i]}], {i, 1, 5}]
Original
Representation a matrix as a colored square shape
Maybe like this.
matrix = Array[RandomChoice[Range[5]] &, {10, 10}];
position1 = Position[matrix, 1];
position2 = Position[matrix, 2];
position3 = Position[matrix, 3];
position4 = Position[matrix, 4];
position5 = Position[matrix, 5];
background = {None, None,
Join[Rule[#, Green] & /@ position1, Rule[#, Orange] & /@ position2,
Rule[#, Cyan] & /@ position3, Rule[#, Yellow] & /@ position4,
Rule[#, White] & /@ position5]};
itemstyle = {Automatic, Automatic};
Grid[matrix, Frame -> All, Background -> background,
ItemStyle -> itemstyle]