1
$\begingroup$

I like to fit the legend to the width of the figure because it is too wide. Is there any code I can add to resolve the issue?

Plot[{output1, output12, output2, output22, growth, growth2}, {t, 0, 
  10000},
 PlotRange -> All,
 AxesLabel -> {Time}, 
 PlotLegends -> 
  Placed[{"H sector's growth rate", 
    "H sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", 
    "L sector's growth rate", 
    "L sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", "Growth rate", 
    "Growth rate with higher \!\(\*SuperscriptBox[\(\[Pi]\), \
\(H\)]\)(PLG)"}, Below],
 AxesStyle -> Black, 
 PlotStyle -> {{Red, Dotted}, {Red}, {Blue, Dotted}, {Blue}, {Black, 
    Dotted}, {Black}}]


enter image description here

$\endgroup$
1
  • $\begingroup$ I just updated the code. $\endgroup$
    – jck21
    Jan 18, 2023 at 23:40

1 Answer 1

4
$\begingroup$
Clear["Global`*"]

Plot[{t, .8 t, .6 t, .4 t, .2 t, .05 t}, {t, 0, 10000},
 PlotRange -> All,
 AxesLabel -> {Time},
 PlotLegends -> Placed[
   LineLegend[{"H sector's growth rate", 
     "H sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", 
     "L sector's growth rate", 
     "L sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", "Growth rate", 
     "Growth rate with higher \!\(\*SuperscriptBox[\(\[Pi]\), \
\(H\)]\)(PLG)"},
    LegendLayout -> {"Column", 2},
    LabelStyle -> 10],
   Below],
 AxesStyle -> Black,
 PlotStyle -> {{Red, Dotted}, {Red}, {Blue, Dotted}, {Blue}, {Black, 
    Dotted}, {Black}},
 ImageSize -> Large]

enter image description here

Plot[{t, .8 t, .6 t, .4 t, .2 t, .05 t}, {t, 0, 10000},
 PlotRange -> All,
 AxesLabel -> {Time},
 PlotLegends -> Placed[
   LineLegend[{"H sector's growth rate", 
     "H sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", 
     "L sector's growth rate", 
     "L sector's growth rate with higher \
\!\(\*SuperscriptBox[\(\[Pi]\), \(H\)]\)(PLG)", "Growth rate", 
     "Growth rate with higher \!\(\*SuperscriptBox[\(\[Pi]\), \
\(H\)]\)(PLG)"},
    LegendLayout -> "Column",
    LabelStyle -> 10],
   Below],
 AxesStyle -> Black,
 PlotStyle -> {{Red, Dotted}, {Red}, {Blue, Dotted}, {Blue}, {Black, 
    Dotted}, {Black}},
 ImageSize -> Medium]

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.