# 2d graphs in a 3d plot

I am trying to create 3d plots with several 2d graphs, like in Plotting several 2d functions in a 3d graph. However the end result looks like this:

Using \closedcycle doesn't help either, as it generates this:

The following is a MWE for the second figure, with a reduced dataset:

\documentclass[12pt]{article}
\usepackage{pgfplots,pgfplotstable}

\pgfplotsset{compat=1.7}

\begin{document}
\begin{tikzpicture}

q   1h  2h  3h  4h
0.01138 124.153702  119.550705  117.984253  115.065399
0.089615    4.255316    4.356256    4.253153    4.040073
0.129441    4.262549    3.756256    3.765975    4.120948
0.254584    2.837865    3.107194    2.983951    2.531952
0.298655    2.638327    2.848219    2.792608    2.729832
}\data

\begin{axis}[
zmode=log,
log origin z=0,
area plot/.style={
fill opacity=0.75,
draw=blue!70!violet,thick,
fill=blue!70!violet!50,
mark=none,
}
]
\pgfplotsinvokeforeach{4,3,2,1}{
\addplot3 [area plot] table [x=q, y expr=#1, z=#1h] {\data} \closedcycle;

}
\end{axis}
\end{tikzpicture}

\end{document}


How can I get this straight?

-
Something seems to be wrong with your example data, I can't compile your MWE (Table '<inline_table>' appears to have too many colum ns in line 2: Ignoring '121.330681'). Could you fix that? –  Jake Nov 29 '12 at 20:17
Done. Thanks for the heads-up =) –  Francisco Nov 29 '12 at 20:20

I don't know if there is a bug. If there is, take this as a workaround; I added redundant points in the curves and removed the contour lines (code below).

\documentclass[12pt]{article}
\usepackage{pgfplots,pgfplotstable}

\begin{document}
\begin{tikzpicture}

q   1h  2h  3h  4h
0.01138 124.153702  119.550705  117.984253  115.065399
0.089615    4.255316    4.356256    4.253153    4.040073
0.129441    4.262549    3.756256    3.765975    4.120948
0.254584    2.837865    3.107194    2.983951    2.531952
0.298655    2.638327    2.848219    2.792608    2.729832
0.298655    1       1       1       1
0.01138     1       1       1       1
0.01138 124.153702  119.550705  117.984253  115.065399
}\data

\begin{axis}[
zmode=log,
log origin z=0,
area plot/.style={
fill opacity=0.75,
draw=blue!70!violet,thick,
fill=blue!70!violet!50,
mark=none,
}
]
\pgfplotsinvokeforeach{4,3,2,1}{
\addplot3 [fill=blue, opacity=0.5,draw=none] table [x=q, y expr=#1, z=#1h] {\data} \closedcycle;

}
\end{axis}
\end{tikzpicture}

\end{document}

-
I don't think this is a bug: \closedcycle in a 3D context doesn't really make sense anyway (except for this rather special case). I think your approach of adding support points is exactly right (it's what I did in my answer to the linked question as well). –  Jake Nov 29 '12 at 21:44
I agree. I kind of knew that using \closedcycle was a mistake form the start, since the pgfplots manual says it might not be a good idea and suggests using --cycle instead. But in my case it's even worse and leads to another version my first figure... I was kind of hoping for a more elegant solution, but I might need to just go with alfC's idea (which is fine, by the way, it does what I need and that's what matters. No offense meant ;) –  Francisco Nov 29 '12 at 21:51
@Jake, yes, it looks like it. The log scale is not the problem even. BTW, I couldn't figure out how to draw the contour of the 3D surface. –  alfC Nov 30 '12 at 0:00