TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

In the meantime Christian has added this feature to PGFPlots and your first given code in the question works fine without any modification, if you update PGFPlots to v1.13 and gives the result of Christians answer.

It also seems that there was a very similar question here.

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.