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.

Calculated data:

data= {{3.54216*10^6, 5.43391*10^6}, {3.5422*10^6, 
      5.43392*10^6}, {3.54224*10^6, 5.43393*10^6}, {3.54215*10^6, 
      5.43395*10^6}, {3.54219*10^6, 5.43396*10^6}, {3.54223*10^6, 
      5.43397*10^6}, {3.54214*10^6, 5.43399*10^6}, {3.54218*10^6, 
      5.434*10^6}, {3.54222*10^6, 5.43401*10^6}, {3.54213*10^6, 
      5.43403*10^6}, {3.54217*10^6, 5.43404*10^6}, {3.54221*10^6, 
      5.43405*10^6}, {3.54212*10^6, 5.43407*10^6}, {3.54216*10^6, 
      5.43408*10^6}, {3.5422*10^6, 5.43409*10^6}};

How can I present these data as an Table {i,x[i],y[i]} next to a graphic as a legend? I tried this finally with:

e = data &;
legends = AccountingForm /@ e[x];

legend = Overlay[{legendMaker[legends]}, Alignment -> {-.5, -.8}, 
  ImageSize -> 400]

using the function legendMaker but I am not happy with my result. The best way would be to have it as an excel-like table. Thanks a lot.

share|improve this question

3 Answers 3

Using Jens's extractStyles function with further styling:

lstplt = ListPlot[List /@ data, PlotMarkers -> {\[FilledCircle], 24}, 
         Frame -> True, ImageSize -> 600];
legendmarkers = extractStyles[lstplt][[2]];
legendlabels =  Map[Style[AccountingForm[#], FontFamily -> "Calibri"] &, data, {-1}];
styledheaders = Style[#, Bold, FontFamily -> "Calibri"] & /@ {"", "X", "Y"};
legendGrd =  Grid[Prepend[ Transpose[Join[{legendmarkers}, Transpose[legendlabels]]],
   styledheaders], Frame -> All, FrameStyle -> GrayLevel[.9],
   Alignment ->{Center, Center}, Background ->{None, {GrayLevel[.5],{GrayLevel[.8]}}}];
Panel@Row[{Show[lstplt, ListPlot[data, Joined -> True, ImageSize -> 600]], legendGrd}, 
      Spacer[5]]

enter image description here

For xCharts with the ChartLegends option, one can use a series of ReplaceAlls to change the content and styling of the legend:

bcdata={RandomChoice[CharacterRange["A", "Z"]], #[[1]], #[[2]], RandomReal[]} & /@ data;
bc = BubbleChart[bcdata[[All, 2 ;;]],
   ChartStyle -> "SolarColors",
   ChartElementFunction -> "NoiseBubble",
   ChartLegends -> 
     Row /@ Map[Style[AccountingForm[#], FontFamily -> "Calibri"] &, bcdata, {-1}],
  Frame -> True, ImageSize -> 400];
headers = {"", "OBS", "X", "Y", "Z"};
styledheaders = Style[#, Bold, FontFamily -> "Calibri"] & /@ headers;

Panel[bc /.
 {Row[x___] :> Sequence[x], Rectangle[__] :> Disk[]} /.
  Grid[{{x_, {y__}}}, z___] :> {x, y} /.
  Column[x___] :> Grid[Prepend[x, styledheaders],
      Frame -> All, FrameStyle -> GrayLevel[.9],
      Alignment -> {Center, Center},
      Background -> {None, {GrayLevel[.5], {GrayLevel[.8]}}}] /. 
 Framed[x__, y___] :> x]

enter image description here

Finally, one can extract the marker shape ("NoiseBubble" in the example above) using

  noiseBble = Cases[bc, PolygonBox[x___] :> Polygon[x], Infinity][[1]];

use it in the legend by replacing

  Rectangle[__]:>Disk[] 

with

 Rectangle[__]:> Polygon[{noiseBble[[1, 1, 1 ;; -1 ;; 3]]}].
share|improve this answer
    
Thanks a lot for this nice solution!! –  Harald Aug 31 '12 at 5:34

My interpretation of "next to a graphic" is slightly different than Vitaliy's:

Framed@Row[
     {ListLinePlot[data/10^6, ImageSize -> 350, PlotLabel -> "My Plot"], 
      Grid[Transpose[{Range@Length@data, Map[AccountingForm, data, {2}]}] /. 
                                                                      {x_, {y__}} -> {x, y}, 
       Frame -> All]}]

Mathematica graphics

share|improve this answer
    
Thanks a lot, this is exactly what I was looking for –  Harald Aug 31 '12 at 5:33

Do you means something like this?

data = Map[AccountingForm, data, {-1}];

Grid[Transpose[Prepend[Transpose[data], Graphics[{ColorData["Rainbow"][#], Disk[]}, 
 ImageSize -> 10] & /@ Range[0, 1, 1/(Length[data] - 1)]]], Frame -> All]

enter image description here

share|improve this answer
    
Thanks a lot, Vitally Kaurov, this was what I was looking for –  Harald Aug 31 '12 at 5:18

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.