5

I have the following code that plots 2D functions in a 3D plot.

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepackage{tikz-3dplot}
\pgfmathdeclarefunction{normal}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[samples=30,
domain=15:25,
xlabel={$x$},
zmin=0,zlabel={$z$},
samples y=0, ytick={7,8,9,10},ylabel={$y$},
area plot/.style={
    fill opacity=0.75,
    draw=none,
    fill=blue!70,
    mark=none,
    smooth
}
]
\addplot3 [area plot] (x,10,{normal(20,1)});
\addplot3 [area plot] (x,9,{normal(20,1)});
\addplot3 [area plot] (x,8,{normal(20,1)});
\addplot3 [area plot] (x,7,{normal(20,1)});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

However I want to swap the x and y-axis. I want to to have for every x-value a normal curve along the y-axis. Is this possible?

1 Answer 1

3

If I understand correctly what you are trying to do, you can swap the first two coordinates in the plot expressions, like this

\addplot3 [area plot] (10,x,{normal(20,1)});
\addplot3 [area plot] (9 ,x,{normal(20,1)});
\addplot3 [area plot] (8 ,x,{normal(20,1)});
\addplot3 [area plot] (7 ,x,{normal(20,1)});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .