I am trying to render a matrix as a depth map:
data = {{1, 1, 1, 1}, {1, 0, 3, 1}, {2, 0, 0, 1}};
ListPlot3D[data, Mesh -> None, InterpolationOrder -> 0,
Filling -> Bottom, FillingStyle -> {Opacity[1]},
ColorFunction -> "SolarColors", ViewPoint -> {Pi, Pi, 5}]
However, for the matrix element with the lowest value, the height of the corresponding bar in the plot is zero. This results in rendering artifacts (z-fighting).
Viewing the graph from below or rotating the graph makes the problem more obvious:
Answer
This is not entirely the same, as it changes coloring and z-scaling, but perhaps something similar may be of help. Essentially, the zero values are lifted by a small increment, while the original z-range is preserved.
data = {{1, 1, 1, 1}, {1, 0, 3, 1}, {2, 0, 0, 1}};
ListPlot3D[data /. x_ /; x < .01 -> 0.01, Mesh -> None,
InterpolationOrder -> 0, Filling -> Bottom,
FillingStyle -> {Opacity[1]}, ColorFunction -> "SolarColors",
ViewPoint -> {Pi, Pi, 5},
PlotRange -> {Automatic, Automatic, {Min[data], Max[data]}}]
EDIT
even better (shorter and broader applicability) as proposed by the OP:
ListPlot3D[data, Mesh -> None, InterpolationOrder -> 0,
Filling -> Bottom, FillingStyle -> {Opacity[1]},
ColorFunction -> "SolarColors", ViewPoint -> {Pi, Pi, 5},
PlotRange -> {Automatic, Automatic, {Min[data] - 0.01, Max[data]}}]
Comments
Post a Comment