How to plot a matrix with 3D style
Graphics primitives is quite elegant:
box[h_, {x_, y_}] := Cuboid[{x, y, 0}, {x + 1, y + 1, h}]
Graphics3D@MapIndexed[box, list, {2}]
It is no less elegant with custom styling:
box[h_, {x_, y_}] := {
ColorData["Rainbow", h/Max[list]],
Cuboid[{x, y, 0}, {x + 1, y + 1, h}]
}
Graphics3D@MapIndexed[box, list, {2}]
Here's an example with the color function that is used by MatrixPlot
, see J.M.'s comment below:
Also:
SeedRandom[1]
list = RandomReal[5, {5, 5}];
BarChart3D:
BarChart3D[Reverse /@ list, ChartLayout -> "Grid",
BarSpacing -> {0, 0}, ColorFunction -> "Rainbow",
"Canvas" -> False, "FaceGrids" -> None][[1]] //
Graphics3D[#, Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}] &
DiscretePlot3D:
iF = Interpolation[Join @@ MapIndexed[Composition[Reverse, List], list, {2}]];
DiscretePlot3D[iF[i, j], {i, 1, Dimensions[list][[1]]}, {j, 1, Dimensions[list][[2]]},
ExtentSize -> Full, FillingStyle -> Opacity[1], ColorFunction -> "Rainbow"]
ListPlot3D:
Normal[ListPlot3D[list, InterpolationOrder -> 0, ColorFunction -> Hue, Mesh -> None]] /.
{Line[__] :> Sequence[], Polygon[x : {__}, VertexColors -> {col_, ___}, ___] :>
{col, EdgeForm[], Opacity[.9], Cuboid @@ ({{1, 1, 0}, 1} Sort[x][[{1, -1}]])}}
You can use ListPlot3D
with InterpolationOrder -> 0
:
ListPlot3D[list, InterpolationOrder -> 0, ColorFunction -> Hue,
Mesh -> None, Filling -> Axis]
But unfortunately I've failed to find a way to color the block under each square accordingly with FillingStyle
or with other means domestic to ListPlot3D
.