1
$\begingroup$

In the code below, how to make PlotLabel automatically show the name of the data sets (i.e., aa, bb, cc)?

aa = RandomReal[1, {5, 5}];
bb = RandomReal[1, {5, 5}];
cc = RandomReal[1, {5, 5}];
Table[MatrixPlot[data, PlotLabel -> ?? ],{data,{aa,bb,cc}}]
$\endgroup$
3
  • $\begingroup$ Row[MapThread[ MatrixPlot[#1, PlotLabel -> #2] &, {{aa, bb, cc}, {"aa", "bb", "cc"}}]] ? $\endgroup$ – Xminer Oct 20 '19 at 20:16
  • $\begingroup$ @Xminer Thanks, but this does not extract the names automatically. $\endgroup$ – xiaohuamao Oct 20 '19 at 20:26
  • 3
    $\begingroup$ Column[MatrixPlot[ToExpression@#, PlotLabel -> #] & /@ {"aa", "bb", "cc"}] $\endgroup$ – Bob Hanlon Oct 20 '19 at 22:24
2
$\begingroup$
Table[MatrixPlot[First @ data, PlotLabel -> data],
    {data, Defer /@ Unevaluated[{aa, bb, cc}]}]

enter image description here

Table[MatrixPlot[ReleaseHold @ data, PlotLabel -> data], 
     {data, HoldForm /@ Unevaluated[{aa, bb, cc}]}]

same picture

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.