3
$\begingroup$

Last time I asked a question about putting the text after the line legend here and it works fine for that example.

enter image description here

LineLegend[{Red, Blue}, {"cubic", "quadratic"}, 
 LegendLayout -> "Column", "MarkerLayout" -> After]

Now I also want to apply this to this PointLegend by adding Method->"MarkerLayout" -> After mentioned by kglr here but it doesn't work. How can I fix this?

ClearAll[legend1]
Options[legend1] = {Joined -> Automatic};
legend1[colors_, polymarkers_, legend__, , OptionsPattern[]] := 
 PointLegend[colors, legend, Joined -> OptionValue[Joined], 
  LegendMarkers -> (ResourceFunction["PolygonMarker"][#, Offset[4], 
       EdgeForm[]] & /@ polymarkers), LegendMarkerSize -> {30, 30}, 
  LegendLayout -> (Column[
      Grid[{##}, Alignment -> {Center, Center}] & /@ #, 
      Spacings -> -1] &), Method->"MarkerLayout" -> After]
colors = ColorData[97, #] & /@ Range[6];
polymarkers = {"DownTriangle", "SevenPointedStar", "FourPointedStar", 
   "Diamond"};
mylegend = 
  MaTeX[TeXForm[#], Magnification -> 0.5] & /@ {{"5X", "6Y", "8Z", 
     "9M", "2K", "2N", "2T", "3N", "5O"}, {"1X", "3Y", "5Z", "2L", 
     "9K", "3Z", "7X", "3P", "2T"}, {"3K", "6M"}, {"3H", "6K"}, {"X4",
      "Y5", "C6", "1K"}, {"X6", "Y6", "C6", "Z6"}};
legend1[colors, polymarkers, mylegend, , Joined -> True]

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

Method is overrided because you specified LegendLayout. The solution is to manually set a "reversed" LegendLayout:

LegendLayout -> (Grid[Reverse /@ #, Alignment -> {Right, Center}, Spacings -> {1, -1}] &)

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.