我对使用还不太熟悉pgfplots
,已经查阅了几个小时的手册,但还是找不到一个优雅的解决方案。我想有两列图例条目,然后在它们下面居中放置一个“标签”。我设法通过调整设置来实现这一点[text width= ]
,但我想知道是否有更好的方法。MWE:
\documentclass[11pt,titlepage]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10,
height=0.5\textwidth,
width=0.8\textwidth,
every axis/.append style={thick}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
legend pos=north west,
legend columns=2,
scaled y ticks = false,
xlabel={Months},
ylabel={Profit},
yticklabel={\$ \pgfmathprintnumber{\tick} },
ymin={-5500},
xmin={0},
xmax={5.5},
ytick={-5500, 0, 5000, 10000, 15000},
xtick={1,2,...,5},
grid=major,
]
\addplot[mark=none, color=red, domain=0:5.5] {900*x -5200};
\addlegendentry{120}
\addplot[mark=none, color=green, domain=0:5.5] {1900*x -5200};
\addlegendentry{130}
\addplot[mark=none, color=blue, domain=0:5.5] {2900*x -5200};
\addlegendentry{140}
\addplot[mark=none, color=orange, domain=0:5.5] {3900*x -5200};
\addlegendentry{150}
\addlegendimage{empty legend}
\addlegendentry[text width=30pt]{Drinks/Day}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}