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.

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

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:

Output

How is it possible to set z coordinate to 0?

share|improve this question
up vote 5 down vote accepted

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:

enter image description here

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}
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.