1
$\begingroup$

I made four plots, named Fig1~Fig4. Then I used Grid to put them together in one figure. Now I wish to add a legend in the bottom of the last figure.

Grid[{{Fig1, Fig2}, {Fig3, Fig4}}, Spacings -> {0, 0}]
$\endgroup$
  • $\begingroup$ I used ListPlot to create the 4 figures, so they are discrete plots. Besides red and blue colors, I wish the legend to be one circle and one square. This is the hard task for me. $\endgroup$ – David Xiaoyu Xu Jun 7 '16 at 10:05
  • $\begingroup$ Have a look Single Legend for a Table of Plots $\endgroup$ – user9660 Jun 7 '16 at 14:41
5
$\begingroup$

You can use Legended (look at documentation to customize for your needs). Dummy data for illustrative purposes:

Legended[Grid[
  Partition[
   Plot[{##}, {x, -1, 1}, PlotStyle -> {Red, Blue}] & /@ {{1 - x, 
      x^2}, {2 - x, x^2 - 1}, {x, 1 - x^2}, {x + 1, 2 - x^2}}, 2]], 
 LineLegend[{Red, Blue}, {"Condition 1", "Condition 2"}]]

enter image description here

$\endgroup$
  • $\begingroup$ I used ListPlot to create the 4 figures, so they are discrete plots. Besides red and blue colors, I wish the legend to be one circle and one square. This is the hard task for me. $\endgroup$ – David Xiaoyu Xu Jun 7 '16 at 10:05
  • $\begingroup$ @DavidXiaoyuXu I posted this only to provide something you could adapt (as you did not provide any information). I suggest you look at documentation of legends and search the site for legends and specific markers on this site. Good luck:) $\endgroup$ – ubpdqn Jun 7 '16 at 10:07
1
$\begingroup$

Maybe this is helpful:

myR = Range[10, 80, 10];

lp1 = ListPlot[Sqrt[Range[myR[[1]]]], PlotStyle -> Red, PlotMarkers -> "☐"];

lp2 = ListPlot[Sqrt[Range[myR[[2]]]], PlotStyle -> Blue, PlotMarkers -> "⦿"];

lp3 = ListPlot[Sqrt[Range[myR[[3]]]], PlotStyle -> Blue, PlotMarkers -> "⦿"];

lp4 = ListPlot[Sqrt[Range[myR[[4]]]], PlotStyle -> Red, PlotMarkers -> "☐"];

Legended[Grid[{{lp1, lp2}, {lp3, lp4}}], LineLegend[{Blue, Red}, {"⦿", "☐"}]]

enter image description here

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