# How to add a 2d plot to a 3d axis drawing?

My task is quite simple. I want to add to my 3d axis drawing a 2d plot. My closes result is this:

\begin{tikzpicture}
\begin{axis}[
axis equal,
view={45}{30},
compat=1.8,
height=10.2cm,
width=9cm,
grid=major,
grid style={dashed, gray!50},
axis lines=middle,
inner axis line style={=>},
yticklabel style={inner ysep=0pt, anchor=south east, font=\tiny},
ytick={-1,...,1},
xticklabel style={inner xsep=0pt, anchor=north west, font=\tiny},
xtick={-1,...,1},
zticklabel style={inner ysep=0pt, anchor=south east, font=\tiny},
ztick={-1,...,1},
ymin=-2,
ymax=2,
xmin=-2,
xmax=2,
zmin=-2,
zmax=2]
\addplot+[color=PlotColorOne, samples=30, domain=0:2*pi, thick, smooth, z=0] ({sin(deg(x))},{cos(deg(x))});
\end{axis}
\end{tikzpicture}


Which results in this:

How is it possible to set z coordinate to 0?

-

## 1 Answer

You can just treat the required 2d plot as a 3d plot with z=0. So using

\addplot3 ({sin(deg(x))},{cos(deg(x))},0)


you get:

## Code:

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
axis equal,
view={45}{30},
compat=1.8,
height=10.2cm,
width=9cm,
grid=major,
grid style={dashed, gray!50},
axis lines=middle,
inner axis line style={=>},
yticklabel style={inner ysep=0pt, anchor=south east, font=\tiny},
ytick={-1,...,1},
xticklabel style={inner xsep=0pt, anchor=north west, font=\tiny},
xtick={-1,...,1},
zticklabel style={inner ysep=0pt, anchor=south east, font=\tiny},
ztick={-1,...,1},
ymin=-2,
ymax=2,
xmin=-2,
xmax=2,
zmin=-2,
zmax=2]
\addplot3[color=red, samples=30, domain=0:2*pi, thick, smooth, z=0] ({sin(deg(x))},{cos(deg(x))},0);
\end{axis}
\end{tikzpicture}

\end{document}
`
-