4
$\begingroup$

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.

$\endgroup$
5
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thanks a lot, Vitally Kaurov, this was what I was looking for $\endgroup$ – Harald Aug 31 '12 at 5:18
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thanks a lot, this is exactly what I was looking for $\endgroup$ – Harald Aug 31 '12 at 5:33
4
$\begingroup$

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]]}].
$\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.