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.

I have used ListLinePlot to generate this grid of plots:

enter image description here

and I want to add a legend in Row Layout below this grid. My code, has as follows:

graphs = Table[
   ListLinePlot[
    Table[Transpose@{vdd, power[[i, j, All]]}, {j, 1, Wl}],
    PlotLabel -> "T=" <> ToString[T[[i]]] <> "\[Degree]C",
    Frame -> {{True, False}, {True, False}},
    FrameLabel -> {"\!\(\*SubscriptBox[\(V\), \(DD\)]\)(V)","P(nW)"},
    AspectRatio -> 1/GoldenRatio,
    ImageSize -> Medium
    ],
   {i, 1, Tl}];
a = {graphs[[1 ;; 3]], graphs[[4 ;; 6]]};
grid = GraphicsGrid[a, Spacings -> Scaled[0], 
   AspectRatio -> 0.6/GoldenRatio];

where vdd[[...]], W[[...]], T[[...]],power[[...,...,...]] are lists with the measured values and each colored curve in the above plots, corresponds for a different (but known) value of W.

I was thinking to use

Column[{grid, 
  LineLegend[{...colors...}, Table[ToString[W[[n]]]<>"nm",{n,1,Wl}], 
   LegendLayout -> "Row"]}]

but I cannot generate the default colour pallete, which Mathematica uses. Also, I need the legend to be justified to the center (presentation purposes, as you can see).

Any help please?

share|improve this question
1  
Default colors: ColorData[1, "ColorList"]. –  kguler Apr 16 at 20:57
    
Thank you kguler. Column[{grid, LineLegend[ColorData[1, "ColorList"], Table[ToString[Round@W[[n]]] <> "nm", {n, 1, Wl}], LegendLayout -> "Row"]}] . The problem now is that the legend entries are not in one row and they are not justified. Anyway great help in so little time! –  jojosthegreat Apr 16 at 21:20
    
LineLegend[1, labels,...] is the shorter version of LineLegend[ColorData[1,"ColorList"], labels, ...]. To prevent line-wrapping you can use something like LineLegend[1, labels, LegendLayout -> (Pane[Row[Flatten@#, Spacer[3]], 1200] &)] or LineLegend[1, labels, LegendLayout -> (Pane[Grid[{Flatten@#}], 1200] &)]. –  kguler Apr 17 at 2:56

1 Answer 1

I guess this could be solved by

defcol[n_] := ColorData[1, "ColorList"][[n]];
Legended[Plot[{Sin[x], Sin[x]^2, Cos[x]}, {x, -2 \[Pi], 2 \[Pi]}],
 Placed[LineLegend[
   {defcol[1], defcol[2], defcol[3]},
   {"S", "S2", "C"},
   LegendLayout -> "Row"], {0.5, -0.1}]]

enter image description here

The position of Legend is defined by option {0.5, -0.1}

This could be applied for any combination of graphical objects, so in your case put Legended around your GraphicsGrid

share|improve this answer

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.