Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
    ]
        \addplot3[red,domain=0:1,fill=blue,opacity=0.5,samples y=0] (2,x,x^2) \closedcycle ;
     \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
    ]
        \addplot[red,domain=0:1,fill=blue,opacity=0.5,samples y=0] {x^2} \closedcycle ;
  \end{axis}
  \end{tikzpicture}
\end{document}

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

share|improve this question

1 Answer 1

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}

enter image description here

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.