# Visualization of an upper triangular matrix without the zeros

I am trying to find a suitable way to visualize the upper half of a matrix. Can anyone be of help ? I have a matrix of the form M[i,j], i=1,....,n and j=i,...,n Using ListPlot3D is not helping as it is also plotting all the M[i,j]=0 for j < i

• You may want MatrixPlot or ArrayPlot. – evanb Dec 1 '17 at 10:20
• stackoverflow.com/questions/2318529/…. Something like this will be helpful – Sayak Dec 1 '17 at 10:38
• Hi, Array plot will work, but I was looking for something like – Sayak Dec 1 '17 at 10:39

ArrayPlot[
Table[If[i > j, 0, RandomReal[]], {i, 10}, {j, 10}],
ColorFunction -> Function[z, If[z == 0, White, Hue[z]]],
Frame -> False] Primarily to illustrate BarLegend. You can omit the text placement. It is just to compare with bar legend.

sa = SparseArray[{i_, j_} /; i < j :> RandomReal, {10, 10}];
Legended[MatrixPlot[sa, Mesh -> All, ColorRules -> {0 -> White},
ColorFunction -> (ColorData["Rainbow"][Rescale[#, {0, 10}]] &),
ColorFunctionScaling -> False, MeshStyle -> White, Frame -> True,
Epilog -> {Text[
NumberForm[Extract[sa, ##],
2], {#[], 10 - #[]} + {-0.5, 0.5}] & /@
sa["NonzeroPositions"]}], BarLegend[{"Rainbow", {0, 10}}]] Note

• you can also use UpperTriangularize to make upper triangular matrix
• you have to deal with different coordinate systems for Plot and MatrixPlot
• ColorFunctionScaling->False was done to get the BarLegend and MatrixPlot to display same scale
• Thank you so much guys. This is very helpful – Sayak Dec 4 '17 at 3:57