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]]
For xCharts
with the ChartLegends
option, one can use a series of ReplaceAll
s 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]
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]]}].