I combined 9 graphs using the GraphicsGrid command. Each graph has six curves. Now I want to draw the legends after combining 9 graphs and showing legends below but not below of each graph. How I do this?

  • $\begingroup$ Maybe put your GraphicsGrid inside a Column where the last element is a SwatchLegend. If you provide some code you will likely get more detailed answers. $\endgroup$ – Gustavo Delfino Sep 13 '17 at 14:20

Sometimes it's easier for me just to build my own legend and insert it in. Something you can use is GridBox to insert your functions then apply a graphic in the last row. This isn't exactly what you described and its a bit messy, but I think you will get the point.

Lets assign the functions we are plotting to an array:

functions = {x, x^2, x^3, x^4, x^5, x^6};

Now, just build your legend entries using whatever line type/shape your graphs have on them using Graphics and set the name of the function next to the entries (this is not completely perfect here, it takes some trial and error on the dimensions and placement)

lines = Flatten[
  Table[{Inset[Graphics[{Blue, Line[{{-.25, 0}, {-0, 0}}]}], 
     Scaled[{0.4, 0.89 - i/10}]], 
    Inset[Style[functions[[i]], 12, Italic], 
     Scaled[{0.53, 0.9 - i/10}]]}, {i, 1, 6}]]

Put these legend entries in a white box

legend = Graphics[{White, Rectangle[{0, 0}]}, Epilog -> {lines}]

And put it at the end of the GridBox function behind your plots

   Table[Plot[functions[[i]], {x, 0, i}], {i, 1, 3}, {j, 1, 3}], {{"",
      legend, ""}}]] // DisplayForm
  • $\begingroup$ Dear thanks for these valuable hints. One more thing that these legends are shown at the end vertically. How we show these legends horizontally . $\endgroup$ – Amin Sep 14 '17 at 17:30
  • $\begingroup$ @Amin you would just have to change the answer function so that your legend ends up in the {{1,4}} position. So answer will have four columns on the first row and three columns in the second. I have not tested, but it should work fine. $\endgroup$ – Haff Sep 14 '17 at 23:40
  • $\begingroup$ Haff, Dear I am not finding the right place where we can put {{1,4}}, please guide me. $\endgroup$ – Amin Sep 15 '17 at 1:01
  • $\begingroup$ @Amin Taking the above suggestion, use GraphicsRow do create a row filled with graphics: GraphicsRow[{GridBox[ Table[Plot[functions[[i]], {x, 0, i}], {i, 1, 3}, {j, 1, 3}]] // DisplayForm, legend}] Also, you can resize the graphics with your mouse after they are displayed. $\endgroup$ – Haff Sep 15 '17 at 4:59

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.