Search code examples
formattingwolfram-mathematicapresentation

Change the Background of a "Parameter Table" in Mathematica


Please consider :

listA = {5, 10, 6, 9, 10, 9, 8, 0, 4, 2};
listB = {2, 8, 7, 1, 7, 6, 10, 5, 1, 5};

Column[Function[listNo, 
                LinearModelFit[listNo, x, x]["ParameterTable"]] /@ 
                {listA, listB}]

enter image description here

Following a previous question on Customize ANOVA Table in Mathematica, I would like to know How can I change the background of the above. I would like each to have a different background color.

Using Belisarius trick I was able to do the below, however, now they are colored, I realize those table are not the same size. Please let me know if there is a way around that display problem.

Blockquote


Solution

  • You could do something like

    Column[Style[#[[1]], Background -> #[[2]]] 
         & /@  ({LinearModelFit[#[[1]], x, x]["ParameterTable"], #[[2]]} 
              & /@ {{listA, Yellow}, {listB, Red}})]
    

    enter image description here

    Edit

    You'll have to work this out a little more if you want a straight ending. Something like:

    listA = {5, 10, 6, 9, 10, 9, 8, 0, 4, 2};
    listB = {2, 8, 7, 1, 7, 6, 10, 5, 1, 5};
    tit = {"", "Estimate", "Standard Error", "t\[Hyphen]Statistic", 
       "P\[Hyphen]Value"};
    
    
    Grid[Flatten[
      Join[{{tit}}, (Join[{#[[1]]}, #[[2]]] & /@ 
           Partition[(Riffle[#["BasisFunctions"], #["ParameterTableEntries"]] &@ 
                      LinearModelFit[#, x, x]), 2] & /@ {listA, listB})], 1], 
     Background -> {{White, {None}}, {None, {Pink, Pink, Yellow, Yellow}}}, 
     Dividers -> {2 -> True, 2 -> True}, 
     Frame -> {{True}, {True}}, 
     FrameStyle -> Directive[Thickness[2], Blue]]
    

    enter image description here