Generate better looking correlation table
Grid
ClearAll[labeledGrid]
labeledGrid[cs_: "GrayTones", is_: {80, 80},
sty_: Directive["TR", FontSize -> 16, Black]] :=
Module[{tbl = Map[Item[Pane[Style[If[NumericQ@#, NumberForm[#, 2], #], sty],
Alignment -> Center, ImageSize -> is],
Background -> If[NumericQ@#, ColorData[cs][(1 + #)/2], None]] &,
Prepend[Join[List /@ #2, #, 2], Prepend[#2, ""]], {2}]},
Grid[tbl, Dividers -> {All, All, {{1, 1} -> False}}, ##3]] &;
labeledGrid[][ccm, mem, FrameStyle -> Gray]
labeledGrid["Rainbow", {50, 50}][ccm, mem, FrameStyle -> Gray]
ArrayPlot
ClearAll[labeledArrayPlot]
labeledArrayPlot[cs_: "GrayTones"] := Module[{epilog =
MapIndexed[Text[Style[# /. x_?NumericQ -> Round[x, 0.01],
Directive["TR", FontSize -> 16, Black]], #2 - .5] &,
Reverse /@ Transpose@ Prepend[Join[List /@ #2, #, 2], Prepend[#2, ""]], {2}]},
ArrayPlot[ArrayPad[#, {{1, 0}, {1, 0}}, White] ,
ColorFunction -> ( ColorData[cs][(1 + #)/2] &),
Epilog -> epilog, ##3,
ColorFunctionScaling -> False, Mesh -> All, ImageSize -> 1 -> 80]] &;
labeledArrayPlot[][ccm, mem]
SeedRandom[1]
mat = RandomReal[1, {7, 7}];
labels = StringTake[#, 3] & /@ RandomWord[7];
labeledArrayPlot["Rainbow"][mat, labels, ImageSize -> 1 -> 50]
How about using MatrixPlot
?
epilog = MapIndexed[Text[Style[Round[#, .01], 10], #2 - 1/2] &, Transpose@Reverse@ccm, {2}];
ticks = Transpose[{Range@Length@mem, mem}];
MatrixPlot[ccm,
Epilog -> epilog,
FrameTicks -> {ticks, ticks, ticks, ticks},
PlotRangePadding -> None,
ColorFunction -> (ColorData["GrayTones"][(1 + #)/2] &),
ColorFunctionScaling -> False]
Readapting my answer here: DensityPlot with text
dim = Dimensions@ccm;
temp = Transpose[{mem}~Join~Transpose@Round[ccm, .01]];
table = Prepend[temp, Flatten@{"", mem}];
background =
Join[{None,
None}, {Flatten[
Table[{i, j} -> ColorData["GrayTones"][table[[i, j]]], {i, 2,
1 + dim[[1]]}, {j, 2, 1 + 3}], 1]}];
Grid[table
, Frame -> All
, Background -> background
, Alignment -> Center
, ItemSize -> All
, Spacings -> {3, 4}
, ItemStyle -> {{Directive[Black, Bold], Automatic}
, {Directive[Black, Bold], Automatic}}]