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.

I have a very simple 3d graph.

\begin{tikzpicture}

\begin{axis}[view={60}{20},
%axis equal image=true,
xlabel=$X(T)$, ylabel={$D(T)$}, zlabel={$V(T)$},
zmin=0
]
\addplot3[surf,shader=flat,z buffer=sort,
samples=30,domain=0:100,y domain=0:100]
{x+y}; 
\end{axis}
\end{tikzpicture}

This code draws a surface. What I would like to see is the volume under the surface to be colored. Moreover I would like to label in some way the filled volume as "defaulted". I went through all the pages of the manual but could not find any solution. Does someone know how to do it?

Thank you very much.

share|improve this question
    
Welcome to TeX.sx! –  lockstep Nov 19 '12 at 11:42
    
Could you explain what do you really mean when you say filled volume. May be an image or something. I want to see the output you are looking for. –  Manuel Nov 19 '12 at 15:43
    
I am looking for this kind of output: \addplot3[...] {x+y}; img109.imageshack.us/img109/752/filled.jpg –  Marco Nov 19 '12 at 17:10
    
You will need to provide something like \fill[red] (axis cs:0,0,0) -- (axis cs:100,0,100); manually after your surf plot (or add feature requests for such a plot type - which might be a "waterfall plot"?). –  Christian Feuersänger Nov 21 '12 at 7:42

1 Answer 1

Unfortunately I only read Christian Feuersänger's comment after putting together exactly what he recommends; so here's what you could do, but you'll need to manually specify points at the edge, which will be quite complicated for curved surfaces:

Code

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{tikzpicture}
\begin{axis}[view={60}{20},
%axis equal image=true,
xlabel=$X(T)$, ylabel={$D(T)$}, zlabel={$V(T)$},
zmin=0
]
\fill[opacity=0.5,red] (axis cs: 0,0,0) -- (axis cs: 100,0,100) -- (axis cs: 100,0,0) -- cycle;
\fill[opacity=0.5,yellow] (axis cs: 0,0,0) -- (axis cs: 0,100,100) -- (axis cs: 0,100,0) -- cycle;
\fill[opacity=0.5,green] (axis cs: 100,0,100) -- (axis cs: 100,100,200) -- (axis cs: 100,100,0) -- (axis cs: 100,0,0) -- cycle;
\fill[opacity=0.5,blue] (axis cs: 0,100,100) -- (axis cs: 100,100,200) -- (axis cs: 100,100,0) -- (axis cs: 0,100,0) -- cycle;
\addplot3[surf,shader=flat,z buffer=sort,samples=30,domain=0:100,y domain=0:100]{x+y}; 
\end{axis}
\end{tikzpicture}

\end{document}

Output

enter image description here


Edit 1: You can also fake the color gradient (in this simple example):

Code

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   view={60}{20},
    xlabel=$X(T)$,
    ylabel={$D(T)$},
    zlabel={$V(T)$},
    zmin=0,
]
\fill[opacity=1,left color=blue, right color=yellow] (axis cs: 0,0,0) -- (axis cs: 100,0,100) -- (axis cs: 100,0,0) -- cycle;
\fill[opacity=1,bottom color=yellow, top color=red] (axis cs: 100,0,100) -- (axis cs: 100,100,200) -- (axis cs: 100,100,0) -- (axis cs: 100,0,0) -- cycle;
\addplot3[surf,shader=flat,z buffer=sort,samples=30,domain=0:100,y domain=0:100]{x+y}; 
\end{axis}
\end{tikzpicture}

\end{document}

Output

enter image description here

share|improve this answer
    
I suspect the red area has to be filled after the yellow one. –  g.kov Jun 3 '13 at 21:41
    
Probably with opacity=1. But here (opacity=0.5) it really does not matter ;) –  Tom Bombadil Jun 3 '13 at 22:19

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.