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.

For this toy problem


    Table[{x, f[x]}, {f, {Sin, Cos}}, {x, 0, Pi, Pi/10.}], 
    PlotRange -> {{0, Pi}, {-1, 1}}, 
    PlotLegend -> {"Sine", "Cosine",}, LegendPosition -> {1.1, -0.4}, 
    PlotMarkers -> Automatic], {k, 1, 6, 1}], 3], Spacings -> 0, 
 ImageSize -> 700]

I was trying to make a single legend (precisely the legend you see here four times) for the entire GraphicsGrid rather than the same legend four times. How do I do so?

Edit: Same question but now with v9 code that doesn't require loading any package:

  Table[ListPlot[{Sqrt[Range[50]], Power[Range[50], (3)^-1]}, 
    PlotLegends -> 
     PointLegend[Automatic, {"one", "two"}, LegendFunction -> "Frame",
       LegendLabel -> "datasets"]], {k, 1, 6}], 3], ImageSize -> 800]

enter image description here

share|improve this question
which version are you using? Version 9 has built-in plot legends which is better than the old package. –  rm -rf Feb 6 at 21:25
I am using v9... –  JohnD Feb 6 at 23:07

1 Answer 1

up vote 3 down vote accepted

You can generate the legends separately with version 9's legends, but you'll have to manually input the colors (i.e. Automatic won't work):

With[{cols = {Red, Blue}},
                    ListPlot[{Sqrt[Range[50]], Power[Range[50], (3)^-1]}, PlotStyle -> cols], 
                    {k, 1, 6}
            ImageSize -> 800
        PointLegend[cols, {"one", "two"}, LegendLayout -> "Row", LegendMarkers -> Automatic,
            LegendFunction -> "Frame", LegendLabel -> "Datasets"]
    Alignment -> Center]

share|improve this answer
You can use LegendMarkers -> Automatic in PointLegend to match PlotMarkers -> Automatic in ListPlot. The OP might want this. –  Szabolcs Feb 6 at 23:20
@Szabolcs Ah yes, thanks. Forgot to add that... Will edit now. –  rm -rf Feb 6 at 23:37
@rm-rf Nice:clean and simple! –  George Wolfe Feb 7 at 5:16

Your Answer


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.