# How to adjust the legend line length in pgfplots

I have a plot using pgfplots but I need to adjust the length of each legend. I can modify the width of each legend line, but I don't know how to modify the length of them. Is there any option to change that?

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
legend style={font=\tiny, draw=none, style={at={(0.6,1)}}, row sep=-0.12cm, inner sep=0pt, line width=0.5pt,}, %is there any line length??
legend entries={A1, A2, A3, A4 A5, A6, A7},
legend columns=2,
]
(5,-4864175164880)
(10,-9728350329760)
(15,-14592525494640)
(20,-19456700659520)
(25,-24320875824400)
(30,-29185050989280)
(35,-34049226154160)
(40,-38913401319040)
(45,-43777576483920)
(50,-48641751648800)
};
(5,292862229381084)
(10,434852463631792)
(15,570475846800798)
(20,737825490819198)
(25,860718238823815)
(30,940754521446225)
(35,1062038363787050)
(40,1127781160335236)
(45,1185587487293437)
(50,1237044668474952)
};
(5,302387809568514)
(10,433265146600492)
(15,568888291277459)
(20,745760136185414)
(25,863891556048562)
(30,1018505467376564)
(35,1114397529527600)
(40,1243595912571978)
(45,1356917686795978)
(50,1438505671531397)
};
(5,292862229381084)
(10,439615017666611)
(15,579999984864317)
(20,680689964623044)
(25,830567187638336)
(30,989945779779292)
(35,1089013026329017)
(40,1192831304307391)
(45,1218906437648680)
(50,1308435574928259)
};
(5,302387809568514)
(10,447552145712824)
(15,632378624837750)
(20,758456796364679)
(25,905150488169182)
(30,1039132937342017)
(35,1177859366612789)
(40,1267392254011344)
(45,1393401240771311)
(50,1495605989719142)
};
(5,292862229381084)
(10,434852463631792)
(15,570475846800798)
(20,737825490819198)
(25,860718238823815)
(30,940754521446225)
(35,1062038363787050)
(40,1142060277409340)
(45,1187173821398126)
(50,1260840969614604)
};
(5,312696217497890)
(10,565002605927478)
(15,857723287379634)
(20,1129748942677279)
(25,1334295395262765)
(30,1579251153778012)
(35,1767865804266326)
(40,1996881068279606)
(45,2225851981990703)
(50,2401688802214620)
};
\end{axis}
\end{tikzpicture}
\end{document}


\pgfplotsset{
compat=1.11,
legend image code/.code={
\draw[mark repeat=2,mark phase=2]
plot coordinates {
(0cm,0cm)
(0.15cm,0cm)        %% default is (0.3cm,0cm)
(0.3cm,0cm)         %% default is (0.6cm,0cm)
};%
}
}


Change the values as you wish.

• I have also use legend cell align=left so that the entries are left aligned.
– user11232
Nov 3, 2014 at 0:56
• It worked but I got this error: ! Package pgfkeys Error: Choice '1.11' unknown in key '/pgfplots/compat/anchors. How can I find out the right compat? Nov 3, 2014 at 0:59
• @emab Update your pgfplots. The latest one is 1.11. The version will be in the log file if you add \listfiles in your document.
– user11232
Nov 3, 2014 at 1:06
• It will work with 1.5 though Nov 3, 2014 at 8:25
• @emab Correct. But I would like to live on the edge always ;)
– user11232
Nov 3, 2014 at 8:44