0
$\begingroup$

I have extracted the following code from my legends plots because I need them individually

LineLegend[{Directive[PointSize[0.00694444444444], 
   AbsoluteThickness[1.6], Black], 
  Directive[PointSize[0.00694444444444], AbsoluteThickness[1.6], 
   Black], Directive[PointSize[0.00694444444444], 
   AbsoluteThickness[1.6], Black], 
  Directive[PointSize[0.00694444444444], AbsoluteThickness[1.6], 
   Black], Directive[PointSize[0.00694444444444], 
   AbsoluteThickness[1.6], Black], 
  Directive[PointSize[0.00694444444444], AbsoluteThickness[1.6], 
   Black], Directive[PointSize[0.00694444444444], 
   AbsoluteThickness[1.6], Black], 
  Directive[PointSize[0.00694444444444], AbsoluteThickness[1.6], 
   Black], Directive[PointSize[0.00694444444444], 
   AbsoluteThickness[1.6], Black], 
  Directive[PointSize[0.00694444444444], AbsoluteThickness[1.6], 
   Black]}, {"m=1", "m=1.5", "m=2", "m=3", "m=10", "m=50", "m=207", 
  "m=400", "m=900", "m=1836"}, 
 LegendMarkers -> {{Graphics[{EdgeForm[None], Disk[{0, 0}]}], 
    Offset[6.272]}, {Graphics[{EdgeForm[None], 
      Polygon[{{-1, -1}, {1, -1}, {1, 1}, {-1, 1}}]}], 
    Offset[6.72]}, {Graphics[{EdgeForm[None], 
      Polygon[{{0, 1}, {1, 0}, {0, -1}, {-1, 0}}]}], 
    Offset[8.16]}, {Graphics[{EdgeForm[None], 
      Polygon[{{0, 1}, {-1, 1 - 3^Rational[1, 2]}, {
        1, 1 - 3^Rational[1, 2]}}]}], 
    Offset[7.6]}, {Graphics[{EdgeForm[None], 
      Polygon[{{0, -1}, {-1, -1 + 3^Rational[1, 2]}, {
        1, -1 + 3^Rational[1, 2]}}]}], 
    Offset[7.68]}, {Graphics[Circle[{0, 0}]], 
    Offset[7.168]}, {Graphics[{EdgeForm[Thickness[Medium]], 
      FaceForm[None], 
      Line[{{-1, -1}, {1, -1}, {1, 1}, {-1, 1}, {-1, -1}}]}], 
    Offset[7.168]}, {Graphics[{EdgeForm[Thickness[Medium]], 
      FaceForm[None], 
      Line[{{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {0, 1}}]}], 
    Offset[8.704]}, {Graphics[{EdgeForm[Thickness[Medium]], 
      FaceForm[None], 
      Line[{{0, 1}, {-1, 1 - Sqrt[3]}, {1, 1 - Sqrt[3]}, {0, 1}}]}], 
    Offset[8.192]}, {Graphics[{EdgeForm[Thickness[Medium]], 
      FaceForm[None], 
      Line[{{0, -1}, {-1, -1 + Sqrt[3]}, {1, -1 + Sqrt[
          3]}, {0, -1}}]}], Offset[8.192]}}, 
 Joined -> {True, True, True, True, True, True, True, True, True, 
   True}, LegendLayout -> "Row"]

which shows legends as rows, but I want to show all of them in a single row, how can I do that?

$\endgroup$
1
  • $\begingroup$ Dear OP, I would like you to unaccept the answer as a proper one has been found. Future visitors to the page must be redirected to correct solutions. $\endgroup$
    – Syed
    Oct 23, 2021 at 10:25

1 Answer 1

2
$\begingroup$

Change the last part to the following: ...

Joined -> {True, True, True, True, True, True, True, True, True, True},
 LegendLayout -> "Row",
 LegendFunction -> "Frame",
 LegendMargins -> {{10, 10}, {10, 10}},
 ImageSize -> {600, 15}
 ]

enter image description here

Curiously, it says that ImageSize is not an option for the LineLegend (at least on v12.2.0) but uses it anyway. I am sitting here thinking, there must be better ways of doing it. Perhaps it inherits properties from the Plot that it is a part of, but I am not sure of the internal details.

$\endgroup$
3
  • $\begingroup$ Thank you sooooo much $\endgroup$
    – Wisdom
    Oct 23, 2021 at 6:45
  • $\begingroup$ See my comment to the main question: the answer there shows the "proper" (but still undocumented) way to force the layout to be a single row $\endgroup$
    – Lukas Lang
    Oct 23, 2021 at 8:40
  • $\begingroup$ Thanks @LukasLang :) Mine is equally undocumented and therefore a new discovery. $\endgroup$
    – Syed
    Oct 23, 2021 at 9:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.