我有一个使用 pgfplots 的图,但我需要调整每个图例的长度。我可以修改每个图例线的宽度,但我不知道如何修改它们的长度。有没有什么选项可以改变这一点?
\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,
]
\addplot coordinates {
(5,-4864175164880)
(10,-9728350329760)
(15,-14592525494640)
(20,-19456700659520)
(25,-24320875824400)
(30,-29185050989280)
(35,-34049226154160)
(40,-38913401319040)
(45,-43777576483920)
(50,-48641751648800)
};
\addplot coordinates {
(5,292862229381084)
(10,434852463631792)
(15,570475846800798)
(20,737825490819198)
(25,860718238823815)
(30,940754521446225)
(35,1062038363787050)
(40,1127781160335236)
(45,1185587487293437)
(50,1237044668474952)
};
\addplot coordinates {
(5,302387809568514)
(10,433265146600492)
(15,568888291277459)
(20,745760136185414)
(25,863891556048562)
(30,1018505467376564)
(35,1114397529527600)
(40,1243595912571978)
(45,1356917686795978)
(50,1438505671531397)
};
\addplot coordinates {
(5,292862229381084)
(10,439615017666611)
(15,579999984864317)
(20,680689964623044)
(25,830567187638336)
(30,989945779779292)
(35,1089013026329017)
(40,1192831304307391)
(45,1218906437648680)
(50,1308435574928259)
};
\addplot coordinates {
(5,302387809568514)
(10,447552145712824)
(15,632378624837750)
(20,758456796364679)
(25,905150488169182)
(30,1039132937342017)
(35,1177859366612789)
(40,1267392254011344)
(45,1393401240771311)
(50,1495605989719142)
};
\addplot coordinates {
(5,292862229381084)
(10,434852463631792)
(15,570475846800798)
(20,737825490819198)
(25,860718238823815)
(30,940754521446225)
(35,1062038363787050)
(40,1142060277409340)
(45,1187173821398126)
(50,1260840969614604)
};
\addplot coordinates {
(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}
答案1
将这些添加到您的代码中。
\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)
};%
}
}
按照您的意愿更改值。