I want to increase the length of the legend symbol (like solid lines, dashed lines, dot dashed lines, dotted lines etc) in the legend box since for dot-dashed lines the length of the symbol is too small to be differentiated by other symbols in the legend box that I use.enter image description here

1 Answer 1


You can adjust the details of the legend through pgfplotsset where you can also adjust the start and end "coordinates" of the legend handles, .e.g,

\pgfplotsset{legend image code/.code={%
   \draw plot coordinates {(0cm,0cm) (0.5cm,0cm)};

Here is a MWE:


\pgfplotsset{legend image code/.code={
        \draw plot coordinates {(0.cm,0cm) (1.5cm,0cm)};

            [legend entries={$E^\ast/E_c=5$, $E^\ast/E_c=3$}]
            \addplot[no markers, red] coordinates {(0,0) (0.4, 0.3) (0.8, 0.5)};
            \addplot[no markers, blue] coordinates {(0.3, 0) (0.4, 1) (0.9, 0)};

  • Thanks for the answer @BanDoP. \pgfplotsset command worked. Now, I can adjust the start and the end of the legend handles and the length of the symbol in the legend box is bigger as I wanted to be. Commented Nov 9, 2023 at 15:23
  • Here is the solution that I obtained using the answer of @BanDoP: image Commented Nov 9, 2023 at 15:26
  • Great, in that case, could you mark the answer as correct?
    – BanDoP
    Commented Nov 9, 2023 at 15:28
  • Just did it @BanDoP. Thanks again. Commented Nov 10, 2023 at 6:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .