2

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}], PointSize@0.01}, 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

我心永恒
  • 1,488
  • 6
  • 9

1 Answers1

4
$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}], PointSize@0.01}, 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

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198