My answer is based upon Öska's answer here. Credits go to him.
A simple example:
legend = {"a", "b", "c"};
values = Range@3;
MatrixPlot[List /@ values,
ColorFunction -> "DarkRainbow",
FrameTicks -> {{True , Thread[{values, legend}]}, {False , False }}]

MatrixPlot[{values},
FrameTicks -> {{False , False}, {True , Thread[{values, legend}]}}]

Update 1
Rotated labels:
values = Range[30];
legend = Map[Rotate[#, Pi/2] &, "Box " <> # & /@ ToString /@ values];
MatrixPlot[{values},
FrameTicks -> {{False, False}, {True, Thread[{values, legend}]}},
ColorFunction -> "Rainbow",
Mesh -> All,
ImageSize -> 600]

Update 2
Based upon Becko's comment:
(a) You can control the size of the legend bar by replacing it with an ArrayPlot
(b) You can control the size of the squares by varying AspectRatio
and ImageSize
For example:
p1 =
ArrayPlot[{dat},
FrameTicks -> {{False, False}, {Thread[{Range@Length@labels, Rotate[#, Pi/2] & /@ labels}], False}},
Frame -> {{False, False}, {True, False}},
PlotRangePadding -> None,
AspectRatio -> 0.25,
ImageSize -> 200];
p2 =
ArrayPlot[{Range[Min[dat], Max[dat]]},
AspectRatio -> 1/10,
FrameTicks -> {{False, False}, {True, False}},
ImageSize -> 200];
Grid[{{p1}, {p2}}]

Grid
in both cases. In order to rotate the text you can useRotate
as inRotate["Text", Pi/2]
. For colors you can scale your number from zero to one and useGraphics[{ColorData["Rainbow"]@number,Rectangle[]}]
. $\endgroup$