# Pgfplots: How to fill area under a curve in a 3d plot similar to \closedcycle in 2d

How can I fill the area under a curve in a 3d plot, similar to the \closedcycle command in ordinary 2d plots? Applying this command does a filling which is not rotated.

Minimal working example:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=3,
zmin=0,zmax=2
]
\end{axis}
\end{tikzpicture}
\end{document}


In 2D it looks like this

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:1
]
\end{axis}
\end{tikzpicture}
\end{document}


How can I easily apply this to a 3D plot?

-

I suppose the answer is to add the required paths manually instead of \closedcycle.

In your case, it would be

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=3,
zmin=0,zmax=2
]
\addplot3[red,domain=0:1,fill=blue,opacity=0.5,samples y=0] (2,x,x^2) -- (axis cs:2,1,0) -- (axis cs:2,0,0);
\end{axis}
\end{tikzpicture}
\end{document}


Unfortunately, both the meaning of \closedcycle and the use-case to "fill everything below the current parameterized plot" needs a careful definition. It would need a feature request if pgfplots should be able to do it automatically.

-