2
$\begingroup$

Consider following example.

  Table[Sin[\[Alpha] x], {\[Alpha], {0, .1, .2, .3, .4, .45}}]], {x, \
-\[Pi], \[Pi]}, PlotStyle -> {Blue, Red, Gray, Cyan, Magenta, Brown}, 
 PlotRange -> {-3, 5}, 
 Epilog -> 
  Inset[Framed[
    Column[{LineLegend[{Blue}, {"    \[Alpha]=0"}], 
      LineLegend[{Red}, {"    \[Alpha]=.1"}], 
      LineLegend[{Gray}, {"    \[Alpha]=.2"}], 
      LineLegend[{Cyan}, {"    \[Alpha]=.3"}], 
      LineLegend[{Magenta}, {"    \[Alpha]=.4"}], 
      LineLegend[{Brown}, {"    \[Alpha]=.45"}]}], 
    RoundingRadius -> 4], Scaled[{.5, 0.55}]]]

I would like to know how to make the font of the legend bigger or smaller.

$\endgroup$

1 Answer 1

4
$\begingroup$
$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

Clear["Global`*"]

colors = {Blue, Red, Gray, Cyan, Magenta, Brown};
values = {0, .1, .2, .3, .4, .45};

Plot[Evaluate@Table[Sin[α x], {α, values}],{x, -π, π},
 PlotStyle -> colors,
 PlotRange -> {-3, 5},
 ImageSize -> 500,
 Epilog -> Inset[LineLegend[colors,
    Style[StringForm["α=``", ToString[#]], 8] & /@ values,
    LegendFunction ->
     (Framed[#, RoundingRadius -> 4, FrameStyle -> Gray] &)],
   Scaled[{.6, 0.7}]]]

enter image description here

Or using PlotLegends

Plot[Evaluate@Table[Sin[α x], {α, values}],
 {x, -π, π},
 PlotStyle -> colors,
 PlotRange -> {-3, 5},
 ImageSize -> 500,
 PlotLegends -> Placed[
   LineLegend[Style[StringForm["α=``", ToString[#]], 8] & /@
     values,
    LegendLayout -> {"Column", 1},
    LegendFunction ->
     (Framed[#, RoundingRadius -> 4, FrameStyle -> Gray] &)],
   Scaled[{.6, 0.7}]]]

enter image description here

Or using LegendLabel and avoiding all the redundant α=

Plot[Evaluate@Table[Sin[α x], {α, values}], {x, -π, π},
 PlotStyle -> colors,
 PlotRange -> {-3, 5},
 ImageSize -> 500,
 PlotLegends -> Placed[
   LineLegend[Style[#, 8] & /@ values,
    LegendLayout -> {"Column", 1},
    LegendFunction ->
     (Framed[#, RoundingRadius -> 4, FrameStyle -> Gray] &),
    LegendLabel -> α],
   Scaled[{.6, 0.7}]]]

enter image description here

$\endgroup$

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.