2
$\begingroup$

I use this

legend10 = Style["point", Black, FontFamily -> "SimSun", 12];
legend11 = Style["label1", Black, FontFamily -> "SimSun", 12];
legend12 = Style["label2", Black, FontFamily -> "SimSun", 12];
markers = Graphics[{Point[{0, 0}], [email protected]}, ImageSize -> Tiny];

markers1 = Graphics[
   Line[{{0, 0.3}, {0.3, 0.3}}], ImageSize -> Tiny];
markers2 = Graphics[{
    Line[{{0, 0.3}, {0.3, 0.3}}]}, ImageSize -> Tiny];
pltlegend = SwatchLegend[
  {Red, Darker@Green, Darker@Cyan},
  {legend10, legend11, legend12},
  LegendMarkers -> {{markers, {10, 10}}, {markers1, {40, 
      5}}, {markers2, {40, 5}}},
  LegendLabel -> 
   Placed[Style["legend", FontFamily -> "SimSun", Bold, 
     FontSize -> 16], {Left, Above}]]

get this:

enter image description here

I want to is

enter image description here

"LegendLabel" and "Legend" are left-aligned

I read a lot of posts from MSE and there seems to be no solution,I form this Left-aligned PlotLabel? ,learn that I can use Labeled function to let Left-aligned PlotLabel

Labeled function seem can not work in LegendLabel

$\endgroup$

1 Answer 1

4
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

table[pairs_] := TableForm[pairs, 
  TableHeadings -> {None, {Style["legend", FontFamily -> "SimSun", 
      Bold, FontSize -> 16]}}, 
  TableAlignments -> Left]

legend10 = Style["point", Black, FontFamily -> "SimSun", 12];
legend11 = Style["label1", Black, FontFamily -> "SimSun", 12];
legend12 = Style["label2", Black, FontFamily -> "SimSun", 12];
markers = Graphics[{Point[{0, 0}], [email protected]}, ImageSize -> Tiny];

markers1 = Graphics[Line[{{0, 0.3}, {0.3, 0.3}}], ImageSize -> Tiny];
markers2 = Graphics[{Line[{{0, 0.3}, {0.3, 0.3}}]}, ImageSize -> Tiny];
pltlegend = 
 SwatchLegend[{Red, Darker@Green, Darker@Cyan}, {legend10, legend11, 
   legend12}, 
  LegendMarkers -> {{markers, {10, 10}}, {markers1, {40, 
      5}}, {markers2, {40, 5}}},
  LegendLayout -> table]

enter image description here

EDIT:

grid[pairs_] := 
 Grid[Prepend[
   pairs, {Style["legend", FontFamily -> "SimSun", Bold, FontSize -> 16], 
    SpanFromLeft}], Alignment -> Left]

pltlegend = 
 SwatchLegend[{Red, Darker@Green, Darker@Cyan}, {legend10, legend11, 
   legend12}, 
  LegendMarkers -> {{markers, {10, 10}}, {markers1, {40, 
      5}}, {markers2, {40, 5}}},
  LegendLayout -> grid]

enter image description here

$\endgroup$
1
  • $\begingroup$ can delete the table line ? $\endgroup$ Jul 15, 2022 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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