Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Using Jens's code:

data = Map[AccountingForm, gedreht , {-1}];
result = Framed@
   Row[{end, 
     Grid[Transpose[{Range@Length@data, 
         Map[AccountingForm, data, {2}]}] /. {x_, {y__}} -> {x, y}, 
      Frame -> All]}];
hdr = {{"Berechnete Koordinaten", SpanFromLeft, SpanFromLeft}, {"Nr.",
     "x", "y"}};
legendmarkers = Range@Length@data;
legendlabels = 
  Map[Style[AccountingForm[#, 10], FontSize -> 20, 
     FontFamily -> "Calibri"] &, data, {-1}];
hdr[[2]] = 
  Style[#, Bold, FontSize -> 22, FontFamily -> "Calibri"] & /@ 
   hdr[[2]];
hdr[[1, 1]] = 
  Style[hdr[[1, 1]], Bold, FontSize -> 26, FontFamily -> "Calibri"];
legendGrd = 
  Grid[hdr~Join~
    Transpose[Join[{legendmarkers}, Transpose[legendlabels]]], 
   Frame -> All, 
   BaseStyle -> {FontSize -> 20, FontFamily -> "Calibri"}, 
   FrameStyle -> GrayLevel[.9], Alignment -> {Center, Center}, 
   Background -> {None, {GrayLevel[.5], 
      GrayLevel[.5], {GrayLevel[.8]}}}];
plan = Panel@Row[{end, legendGrd}, Spacer[5]]

I sometimes get pretty huge tables for the legend of a figure:

Table

How can I split this table in subtables of, say, 20 lines and to arrange them horizontally?

Thanks a lot!!

share|improve this question
    
partition this: Transpose[Join[{legendmarkers}, Transpose[legendlabels]]] into the size you want. You will have to remake the header to match the dimensions. –  Mike Honeychurch Nov 3 '12 at 22:13
    
It appears that neither gedreht nor end are defined. I cannot find them in Jens post either. –  David Carraher Nov 3 '12 at 22:30
    
you are right. "end" is defined as: end = Overlay[{Show[g, plot1a], legendMaker[textLabels, PlotStyle -> manualPlotstyles, PlotMarkers -> manualMarkers, Background -> Directive[Opacity[.5], Black], "LegendLineAspectRatio" -> .3, "LegendGridOptions" -> {Alignment -> Left, Spacings -> {0.7, .25}, Background -> {{GrayLevel[.8], None}, None}}]}, Alignment -> {-.55, -.620}]; and "gedreht" is defined as r = RotationTransform[grad, {x1, y1}]; r[ungedreht]; gedreht = r[ungedreht]; within a larger code. I just used Jen's code as a part of my code –  Harald Nov 3 '12 at 23:41
    
Similar question: [mathematica.stackexchange.com/q/11849/3056] –  kirma Nov 4 '12 at 9:53

1 Answer 1

up vote 5 down vote accepted
ClearAll[divideTblF, gridF];
(* a function to re-arrange an n-by-m list into an r-by-(m n / r) list:   *)
divideTblF[table_List, rows_Integer] :=  Module[{dims = Dimensions[table], r},
r = Min[rows, First@dims];
 Flatten /@ Transpose[Partition[table, r, r, 1, {ConstantArray[Null, Last@dims]}]]];
(* grid with legend and column headers added to the input table: *)
gridF[x_, legendheader_, colheaders_, opts : OptionsPattern[]] :=
Grid[Join[{{legendheader, SpanFromLeft},
  colheaders[[Mod[Range[Last@Dimensions[x]], Length[colheaders], 1]]]}, x],
   FilterRules[{opts}, Options[Grid]]];

Update: a more elegant alternative to Flatten/@Transpose[...] is to use Join[##,2]&@@(...):

 divideTblF2[table_List, rows_Integer] := Module[{dims = Dimensions[table], 
       r = Min[rows, First@Dimensions[table]] },
    Join[##, 2] & @@ (Partition[table, r, r, 1, {ConstantArray[Null, Last@dims]}])]

Examples:

dataTable = {{11, 12, 13}, {21, 22, 23}, {31, 32, 33}, {41, 42, 43},
  {51, 52, 53}, {61, 62, 63}};
dataTable // Grid

enter image description here

Column[#, Spacer[5], Frame -> All] &@
  (gridF[divideTblF[dataTable, #], "legend", {"col1", "col2", "col3"},
      Dividers -> All] & /@ {6, 5, 4, 3, 2})

enter image description here

share|improve this answer
    
thanks a lot, I will have a deeper look at your code tomorrow morning, now (at 1 a.m.) I should finish my work... –  Harald Nov 3 '12 at 23:59
    
thanks a lot for your answer and for your code. It is of great help for me!!! –  Harald Nov 4 '12 at 11:39
    
@Harald, my pleasure. Glad it was useful for you. –  kguler Nov 4 '12 at 11:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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