\subsection{Closing Plots (Filling the Area Under Plots)} \begin{command}{\closedcycle} Provide |\closedcycle| as \meta{trailing path commands} after |\addplot| to draw a closed line from the last plot coordinate to the first one. Use |\closedcycle| whenevery you intend to fill the area under a plot. \begin{codeexample}[] \begin{tikzpicture} \begin{axis} \addplot {x^2+2} \closedcycle; \end{axis} \end{tikzpicture} \end{codeexample} \begin{codeexample}[] \begin{tikzpicture} \begin{axis} \addplot+[fill] {x^2+2} \closedcycle; \end{axis} \end{tikzpicture} \end{codeexample} In case of stacked plots, |\closedcycle| connects the current plot with the previous plot instead of connecting with the $x$~axis\footnote{The implementation for stacked plots requires some additional logic to determine the filled area: \lstinline{\\closedcycle} will produce a \texttt{plot coordinates} command with \emph{reversed} coordinates of the previous plot. This is usually irrelevant for end users, but it assumes that the plot's type is symmetric. Since constant plots are inherently unsymmetric, \lstinline{\\closedcycle} will use \texttt{const plot mark right} as reversed sequence for \texttt{const plot mark left}.}. \begin{codeexample}[] \begin{tikzpicture} \begin{axis}[stack plots=y] \addplot+[fill] coordinates {(0,1) (1,1) (2,2) (3,2)} \closedcycle; \addplot+[fill] coordinates {(0,1) (1,1) (2,2) (3,2)} \closedcycle; \end{axis} \end{tikzpicture} \end{codeexample} \end{command}